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
| Option Explicit
Public Sub copie_colonnes_MarcelG()
Dim wks_origine As Worksheet
Dim wks_destin As Worksheet
With ThisWorkbook
Set wks_origine = .Worksheets("OD_PRIORITY")
Set wks_destin = .Worksheets("Donnees_access")
End With
Dim dernl1 As Long, dernl2 As Long, dernl As Long
Dim tablo_col As Variant
Dim i As Integer
Dim col As Variant
tablo_col = Array(12, 10, 11, 9, 13, 29, 34, 35)
i = 0
With wks_origine
dernl1 = .Range("AK2:AK" & .Rows.Count).Find(what:="N", searchdirection:=xlPrevious, searchorder:=xlByRows, LookIn:=xlValues).Row
dernl2 = .Range("AK2:AK" & .Rows.Count).Find(what:="O", searchdirection:=xlPrevious, searchorder:=xlByRows, LookIn:=xlValues).Row
dernl = Application.WorksheetFunction.Max(dernl1, dernl2)
For Each col In tablo_col
i = i + 1
.Range(.Cells(2, col), .Cells(dernl, col)).Copy
wks_destin.Cells(2, i).PasteSpecial Paste:=xlValues
Next col
End With
Application.CutCopyMode = False
Set wks_destin = Nothing
Set wks_origine = Nothing
End Sub |
Partager