IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

Intersection en fonction de deux valeurs (ligne - colonne) [XL-2003]


Sujet :

Macros et VBA Excel

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre Expert Avatar de QuestVba
    Homme Profil pro
    Enseignant
    Inscrit en
    Juillet 2012
    Messages
    2 475
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : Belgique

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Service public

    Informations forums :
    Inscription : Juillet 2012
    Messages : 2 475
    Par défaut Intersection en fonction de deux valeurs (ligne - colonne)
    Bonjour le Forum,

    Je mets tout mais vous trouverez certainement la réponse plus facilement que moi. J'ai hérité de ces trois fichiers.

    • Copie de copie de essai congébis 761 : permet d'ouvrir l'écran d'accueil pour demande de congé
    • Congé761 : fichier permettant de gérer ce qui a été demandé et quand
    • Classeur des congés 761: est un tableau reprenant
      C1:AR1 : prénom du personnel
      C2:AR2 : numéro d'agent
      Colonne A : numéro de la date se trouvant dans B


    Pour le moment, le fichier "Copie de Copie de essai congésbis 761" a un UserForm "periode" qui permet l'encodage et après avoir cliquer sur "envoi de la demande", les données sont introduites dans le tableau. Mais ce n'est pas très facile d'ajouter ou de retirer un agent car cela fonctionne avec le code colonne de chacun. Je m'explique le système sait que Michèle (00000332) est le code "2" ce qui correspond à la colonne C. Mais si un changement intervient, je dois tout changer. Voci le code:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    Private Sub CommandButton1_Click()
        Sheets("test").Activate
        Range("f11").Activate
        ActiveCell = ComboBox1.Value
        Range("j11").Activate
        ActiveCell = ComboBox2.Value
        Range("b25").Activate
        ActiveCell = TextBox1.Value
     
    '   valeur des motifs
        Range("f19").Activate
        ActiveCell = ComboBox3.Value
        Range("i19").Activate
        ActiveCell = ComboBox4.Value
        Range("l19").Activate
        ActiveCell = ComboBox5.Value
     
        période.Hide
     
    '   test # nature
        Dim nat1, nat2, nat3
        nat1 = Cells(27, 8).Value
        nat2 = Cells(27, 11).Value
        nat3 = Cells(27, 14).Value
     
        If nat1 = 1 And nat2 = 1 Then MsgBox "Erreur: nombre demi-journées"
        If nat1 = 1 And nat3 = 1 Then MsgBox "Erreur: nombre demi-journées"
        If nat1 = 1 And nat2 = 1 Then période.Show
        If nat1 = 1 And nat3 = 1 Then période.Show
     
        If nat1 = 0 And nat2 = 0 And nat3 = 0 Then MsgBox "Erreur: vous devez introduire la nature du congé"
        If nat1 = 0 And nat2 = 0 And nat3 = 0 Then période.Show
     
    '   envoi des données dans BD_Congés
        Dim dat101, dat102, nature1, nature2, nature3, natureX, agentX, comm
        agentX = Cells(2, 1).Value
        dat101 = Cells(17, 1).Value
        dat102 = Cells(17, 2).Value
        nature1 = Cells(19, 6).Value
        nature2 = Cells(19, 9).Value
        nature3 = Cells(19, 12).Value
        comm = Cells(25, 2).Value
        If nature1 <> "" Then natureX = nature1
        If nature1 = "" Then natureX = nature2 + "/" + nature3
        If agentX = "00061141" Or agentX = "00000332" Or agentX = "00061404" And nature1 <> "" Then natureX = natureX + "!"
    '    If agentX = "00061141" Or agentX = "00000332" Or agentX = "00061404" And nature1 = "" Then natureX = nature2 + "/" + nature3 + "!"
     
        '   permet d'ouvrir le fichier en lecture seule avec boucle si occupé
    Line2:
                Workbooks.Open Filename:= _
                    "I:\Bruxelles-Brussel\PFG\Pierre V - 610\CALENDRIER DES CONGES DR\Classeur des congés761.xls"
                If ActiveWorkbook.ReadOnly Then ouv = 1 Else ouv = 0
                If ActiveWorkbook.ReadOnly Then ActiveWorkbook.Close 'Application.Quit
                If ouv = 1 Then GoTo Line2
    '   fin boucle si occupé
     
        ActiveSheet.Unprotect Password:="onafts"
     
        For i = dat101 To dat102
     
        Columns("A:A").Select
        Range("a1").Activate
        Dim cellagent
     
            If agentX = "00000332" Then cellagent = 2
            If agentX = "00061404" Then cellagent = 3
            If agentX = "00000831" Then cellagent = 4
            If agentX = "00000262" Then cellagent = 5
            If agentX = "00060046" Then cellagent = 6
            If agentX = "00000395" Then cellagent = 7
            If agentX = "00000386" Then cellagent = 8
            If agentX = "00060106" Then cellagent = 9
            If agentX = "00060787" Then cellagent = 10
            If agentX = "00061227" Then cellagent = 11
            If agentX = "00061427" Then cellagent = 12
            If agentX = "00062130" Then cellagent = 13
            If agentX = "00000397" Then cellagent = 14
            If agentX = "00000854" Then cellagent = 15
            If agentX = "00062171" Then cellagent = 16
            If agentX = "00062083" Then cellagent = 17
            If agentX = "00062114" Then cellagent = 18
            If agentX = "00061595" Then cellagent = 19
            If agentX = "00061581" Then cellagent = 20
            If agentX = "00102361" Then cellagent = 21
            If agentX = "00000388" Then cellagent = 22
            If agentX = "00061697" Then cellagent = 23
            If agentX = "00061949" Then cellagent = 24
            If agentX = "00000385" Then cellagent = 25
            If agentX = "00062095" Then cellagent = 26
            If agentX = "00000975" Then cellagent = 27
            If agentX = "00062068" Then cellagent = 28
            If agentX = "00062084" Then cellagent = 29
            If agentX = "00061978" Then cellagent = 30
            If agentX = "00000357" Then cellagent = 31
            If agentX = "00062085" Then cellagent = 32
            If agentX = "00062137" Then cellagent = 33
            If agentX = "00000392" Then cellagent = 34
            If agentX = "00000699" Then cellagent = 35
            If agentX = "00061951" Then cellagent = 36
            If agentX = "00000381" Then cellagent = 37
            If agentX = "00000394" Then cellagent = 38
            If agentX = "00061580" Then cellagent = 39
            If agentX = "00000608" Then cellagent = 40
            If agentX = "00061855" Then cellagent = 41
            If agentX = "00061979" Then cellagent = 42
            If agentX = "00060739" Then cellagent = 43
     
     
            Selection.Find(What:=i, After:=ActiveCell, LookIn:=xlValues, _
                LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                MatchCase:=False, SearchFormat:=False).Activate
     
            ActiveCell.Offset(rowoffset:=0, columnoffset:=cellagent).Activate
            If ActiveCell <> "" Then GoTo line3
            ActiveCell = natureX
            If comm = "" Then GoTo line3
            ActiveCell.AddComment comm
            ActiveCell.comment.Visible = False
    line3:
     
        Next i
        ActiveSheet.Protect Password:="onafts", DrawingObjects:=True, contents:=True, Scenarios:=True
        ActiveWorkbook.Save
        ActiveWindow.Close
     
    line123:
     
        Dmd_congés_Vérif.Show
     
    End Sub
    Ma question: quelle commande faut-il utiliser pour trouver l'intersection entre le nom de la personne (username) en ligne 1 et la date en colonne 1 ?

    Je ne sais pas si c'est suffisamment compréhensible. Posez vos questions si un doute ? Merci.
    Fichiers attachés Fichiers attachés

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [XL-2010] Supprimer des lignes en fonction de la valeur de la cellule de deux colonnes
    Par jérémyp8 dans le forum Macros et VBA Excel
    Réponses: 16
    Dernier message: 18/07/2013, 09h25
  2. [XL-2007] condition valeur ligne ,colonne+1
    Par pilounet54 dans le forum Macros et VBA Excel
    Réponses: 12
    Dernier message: 04/04/2012, 21h56
  3. [XL-2007] Fonction retournant deux valeurs
    Par locosr dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 11/05/2011, 20h11
  4. Groupement de ligne en fonction de la valeur de 2 colonnes
    Par girardinho dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 16/07/2010, 20h32
  5. Réponses: 1
    Dernier message: 10/02/2008, 19h56

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo