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
| Sub Import()
Dim NomColonne4 As String, compteur4 As Long
Dim FeuilleSource9 As Worksheet, tmpPlage4 As Range, DiscPlage4 As Range
Application.Workbooks.Open ("C:\******\***\Exemple.xls")
Set FeuilleSource9 = Workbooks("Exemple").Worksheets(1)
With FeuilleSource9
For compteur4 = 1 To 4
NomColonne4 = Choose(compteur4, "Creation Date", "Format", "Product", "Contact Name")
Set tmpPlage4 = .Cells.Find(what:=NomColonne4, MatchCase:=False)
If Not tmpPlage4 Is Nothing Then
Set tmpPlage4 = .Range(tmpPlage4, tmpPlage4.End(xlDown)).SpecialCells(xlCellTypeConstants)
If Not DiscPlage4 Is Nothing Then
Set DiscPlage4 = Application.Union(DiscPlage4, tmpPlage4)
Else
Set DiscPlage4 = tmpPlage4
End If
Else
MsgBox " colonne " & NomColonne4 & " non trouvée"
End If
Next compteur4
End With
End Sub |
Partager