insertion de 2 codes vba ds le même module

blancolie

XLDnaute Impliqué
Bonjour,

dans le même module, je voudrais inserer plusieurs fois ce code mais à chaque fois, il y aura un nouveau nom de tableau. Dans ce cas n°1, c'est HDV mais l'autre sera clemenceau et etc etc.

Mais je sais que je peux pas insérer plusieurs fois cette ligne car cela ne marchera pas.
VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With [HDV]
    With .Rows(.Rows.Count + 1)
        If Not Intersect(ActiveCell, .Cells(1)) Is Nothing And .Cells(0, 1) <> "" Then
            .Rows(0).Copy .Cells(1)
            .SpecialCells(xlCellTypeConstants).ClearContents
        End If
    End With
End With
End Sub

Comment puis je faire ?

merci de votre aide
 

blancolie

XLDnaute Impliqué
j'ai trouvé la solution :

la voici :

VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With [HDV]
    With .Rows(.Rows.Count + 1)
        If Not Intersect(ActiveCell, .Cells(1)) Is Nothing And .Cells(0, 1) <> "" Then
            .Rows(0).Copy .Cells(1)
            .SpecialCells(xlCellTypeConstants).ClearContents
        End If
    End With
End With
With [Clemenceau]
    With .Rows(.Rows.Count + 1)
        If Not Intersect(ActiveCell, .Cells(1)) Is Nothing And .Cells(0, 1) <> "" Then
            .Rows(0).Copy .Cells(1)
            .SpecialCells(xlCellTypeConstants).ClearContents
        End If
    End With
End With
End Sub
 

Discussions similaires