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
| Option Explicit
Sub Adrien_ax()
Dim oRange_ori As Range
Dim oRange_fin As Range
Dim i As Integer, j As Integer
Dim Classeur_source As String
Dim Classeur_cible As String
Classeur_source = "New Failed Boards.xlsm"
Classeur_cible = "Cartes en panne.xlsx"
With Workbooks(Classeur_source)
With .Worksheets("Feuil1")
Set oRange_ori = .Range("A1")
For i = 0 To .Columns(1).Find("*", , , , xlByColumns, xlPrevious).Row - 1
If FeuilleExiste(Classeur_cible, CStr(oRange_ori.Offset(i, 0))) Then
With Workbooks(Classeur_cible).Worksheets(CStr(oRange_ori.Offset(i, 0)))
Set oRange_fin = .Columns(1).Find("*", , , , xlByColumns, xlPrevious).Offset(1, 0)
For j = 0 To 5
oRange_fin.Offset(0, j) = oRange_ori.Offset(i, j)
Next j
End With
Else
MsgBox "Attention ! Le modèle " & CStr(oRange_ori.Offset(i, 0)) & " ne possède pas de feuille dans le classeur " & Classeur_cible & "."
End If
Next i
End With
End With
End Sub
Public Function FeuilleExiste(strNomClasseur As String, strNomFeuille As String) As Boolean
FeuilleExiste = Not (IsError(Evaluate("='[" & strNomClasseur & "]" & strNomFeuille & "'!A1")))
End Function |
Partager