Bonjour le forum,
j ai un fichier "testforward" ou a partir de la colonne G4, j ai des noms.
la macro doit aller verifier si le nom se trouve :
1) dans le fichier nomme "Danhmuc8020.xls",
2) si le stock ne se trouve pas dans le fichier "Danhmuc8020.xls", alors verifier si le nom est dans le fichier "DANHMUCCAMCO.xls" , si oui alors
3) affiche un msgbox avec "le nom du fichier ou se trouve le stock"
4) la comparaison se fait jusqua la macro rencontre une cellule vide du fichier "testforward"
voici le code :
Private Sub compare()
myway = ActiveWorkbook.Path & "\"
Dim cp As Integer
Dim K As Integer
Dim testforward As Workbook
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").Cells(Rows.Count, 7).End(3).Row
cp = Application.Match(Cells(K, 7), Danhmuc8020.Sheets("Hanmucgiaingan").Range("B3:B16"), 0)
If cp = Cells(K, 7) Then
MsgBox "ok"
Else
cp = Application.Match(Cells(K, 7), DANHMUCCAMCO.Sheets("HOSE").Range("B4:B"), 0)
If cp = Cells(4, K) Then
MsgBox "DANHMUCCAMCO"
K = K + 1
End If
End If
Next K
End Sub
j ai une erreur "type mismatch" quand la macro arrive sur la ligne "cp = application.match"
j ai beau cherche, je ne trouve la solution.
merci de votre aide
clt
j ai un fichier "testforward" ou a partir de la colonne G4, j ai des noms.
la macro doit aller verifier si le nom se trouve :
1) dans le fichier nomme "Danhmuc8020.xls",
2) si le stock ne se trouve pas dans le fichier "Danhmuc8020.xls", alors verifier si le nom est dans le fichier "DANHMUCCAMCO.xls" , si oui alors
3) affiche un msgbox avec "le nom du fichier ou se trouve le stock"
4) la comparaison se fait jusqua la macro rencontre une cellule vide du fichier "testforward"
voici le code :
Private Sub compare()
myway = ActiveWorkbook.Path & "\"
Dim cp As Integer
Dim K As Integer
Dim testforward As Workbook
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").Cells(Rows.Count, 7).End(3).Row
cp = Application.Match(Cells(K, 7), Danhmuc8020.Sheets("Hanmucgiaingan").Range("B3:B16"), 0)
If cp = Cells(K, 7) Then
MsgBox "ok"
Else
cp = Application.Match(Cells(K, 7), DANHMUCCAMCO.Sheets("HOSE").Range("B4:B"), 0)
If cp = Cells(4, K) Then
MsgBox "DANHMUCCAMCO"
K = K + 1
End If
End If
Next K
End Sub
j ai une erreur "type mismatch" quand la macro arrive sur la ligne "cp = application.match"
j ai beau cherche, je ne trouve la solution.
merci de votre aide
clt
Dernière édition: