Bonjour,
j ai ecris un code mais ca bug.
la situation est : j ai un workbook source nomme "testforward", colonne G et a
partir de G4, j ai des noms.
la macro doit verifier pour chaque cellule de G4 jusqu a la premiere cellule
vide du workbook "testforward" ou se trouve ce nom ; soit dans le workbook
"danhmuc8020" ou dans le workbook "danhmuc", et ensuite dans un msgbox specifier
dans quel workbook se trouve le nom.
voici le code ecrit :
Sub compare()
myway = ActiveWorkbook.Path & "\"
Dim cp As Integer
Dim K As Integer
Dim Danhmuc8020 As Workbook
Set Danhmuc8020 = GetObject(myway & "\Danhmuc8020.xls" )
Dim DANHMUCCAMCO As Workbook
Set DANHMUCCAMCO = GetObject(myway & "\DANHMUCCAMCO.xls" )
For K = 4 To Sheets("FW" ).[G65000].End(4).Row
cp = 0
cp = Application.Match(Cells(K, 7),
Danhmuc8020.Sheets("Hanmucgiaingan" ).[B3:B16], 0)
If cp = 0 Then
MsgBox "ok"
Else
cp = Application.Match(Cells(K, 7), DDANHMUCCAMCO.Sheets("HOSE" &
"HASTC" ).[B4:B], 0)
If cp = Cells(4, K) Then
MsgBox "DANHMUCCAMCO"
K = K + 1
End If
Next
End Sub