comparer une colonne d'un workbook source avec 2 autres workbook

comparer une colonne d'un workbook source avec 2 autres workbook - VB/VBA/VBS - Programmation

Marsh Posté le 09-01-2010 à 15:05:54    

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
 

Reply

Marsh Posté le 09-01-2010 à 15:05:54   

Reply

Marsh Posté le 10-01-2010 à 12:15:31    

le bug est "type mismatch: quand la macro arrive a la ligne "cp = application.match...."

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed