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
|
Sub Macro16()
'
' Macro16 Macro
'
' Keyboard Shortcut: Ctrl+o
'
Dim j, i, k As Integer
Dim MyCart()
Dim LookFor()
Dim LineRef, ColRef As Variant
Dim CavSel As Variant
Dim chaine As String
Dim val1 As Range
Sheets("my_selection").Activate
MyCart = Array("y=0", "E", "D", "C", "B", "A") 'tableau qui contient les noms des sheets que je veux utiliser
For j = 0 To 10
Sheets("my_selection").Activate
Set CavSel = Cells.Find(What:=MyCart(j), After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False) '.Activate
LineRef = CavSel.Row
ColRef = CavSel.Column + 1
i = 0
Do While Not (Cells(LineRef, ColRef) = "")
LookFor(i) = Cells(LineRef, ColRef).Value
ColRef = ColRef + 1
i = i + 1
Loop
'Récupération des indice des cases à utiliser pour la coupe correspondante
Sheets(MyCart(j)).Activate -------------->subscript out of range
ReDim Col(UBound(LookFor))
For k = 0 To UBound(LookFor)
Set val1 = Cells.Find(What:=LookFor(i), After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False) '.Activate
chaine = CStr(val1.Address)
Col(k) = Left(chaine, Len(chaine) - 2)
Col(k) = Right(chaine, Len(chaine) - 2)
Next k
Next j
End Sub |
Partager