comparer une colonne d'un workbook source avec 2 autres workbook
3 réponses
ktran
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
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Jacky
Bonjour,
Code non testé..mais Si ceci
For K = 4 To Sheets("FW").[G65000].End(4).Row
doit boucler de la colonne "G" de la ligne 4 à la dernière ligne occupée, il faut remplacer End(4) par End(3) ou compatible xl2007 For K = 4 To Sheets("Feuil1").Cells(Rows.Count, 7).End(3).Row
Bon courage -- Salutations JJ
"ktran" a écrit dans le message de news:
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
Bonjour,
Code non testé..mais
Si ceci
For K = 4 To Sheets("FW").[G65000].End(4).Row
doit boucler de la colonne "G" de la ligne 4 à la dernière ligne occupée, il
faut remplacer End(4) par End(3)
ou compatible xl2007
For K = 4 To Sheets("Feuil1").Cells(Rows.Count, 7).End(3).Row
Bon courage
--
Salutations
JJ
"ktran" <nospam_kienquoc.tran@yahoo.fr> a écrit dans le message de news:
BN-dnc5QqOxR79XWRVn_vwA@giganews.com...
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
doit boucler de la colonne "G" de la ligne 4 à la dernière ligne occupée, il faut remplacer End(4) par End(3) ou compatible xl2007 For K = 4 To Sheets("Feuil1").Cells(Rows.Count, 7).End(3).Row
Bon courage -- Salutations JJ
"ktran" a écrit dans le message de news:
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
Jacky
Re.. For K = 4 To Sheets("FW").Cells(Rows.Count, 7).End(3).Row Evidemment et non pas For K = 4 To Sheets("Feuil1").Cells(Rows.Count, 7).End(3).Row
-- Salutations JJ
"Jacky" a écrit dans le message de news: %
Bonjour,
Code non testé..mais Si ceci
For K = 4 To Sheets("FW").[G65000].End(4).Row
doit boucler de la colonne "G" de la ligne 4 à la dernière ligne occupée, il faut remplacer End(4) par End(3) ou compatible xl2007 For K = 4 To Sheets("Feuil1").Cells(Rows.Count, 7).End(3).Row
Bon courage -- Salutations JJ
"ktran" a écrit dans le message de news:
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
Re..
For K = 4 To Sheets("FW").Cells(Rows.Count, 7).End(3).Row
Evidemment et non pas
For K = 4 To Sheets("Feuil1").Cells(Rows.Count, 7).End(3).Row
--
Salutations
JJ
"Jacky" <Dupond@marcel.fr> a écrit dans le message de news:
%235xuOKUkKHA.1824@TK2MSFTNGP04.phx.gbl...
Bonjour,
Code non testé..mais
Si ceci
For K = 4 To Sheets("FW").[G65000].End(4).Row
doit boucler de la colonne "G" de la ligne 4 à la dernière ligne occupée,
il
faut remplacer End(4) par End(3)
ou compatible xl2007
For K = 4 To Sheets("Feuil1").Cells(Rows.Count, 7).End(3).Row
Bon courage
--
Salutations
JJ
"ktran" <nospam_kienquoc.tran@yahoo.fr> a écrit dans le message de news:
BN-dnc5QqOxR79XWRVn_vwA@giganews.com...
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
Re.. For K = 4 To Sheets("FW").Cells(Rows.Count, 7).End(3).Row Evidemment et non pas For K = 4 To Sheets("Feuil1").Cells(Rows.Count, 7).End(3).Row
-- Salutations JJ
"Jacky" a écrit dans le message de news: %
Bonjour,
Code non testé..mais Si ceci
For K = 4 To Sheets("FW").[G65000].End(4).Row
doit boucler de la colonne "G" de la ligne 4 à la dernière ligne occupée, il faut remplacer End(4) par End(3) ou compatible xl2007 For K = 4 To Sheets("Feuil1").Cells(Rows.Count, 7).End(3).Row
Bon courage -- Salutations JJ
"ktran" a écrit dans le message de news:
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
ktran
ktran a écrit le 09/01/2010 à 13h12 :
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
j ai bien re-ecris comme tu me la conseille mais j ai toujours un erreur "mismatch" comme la macro arrive sur ligne : cp = application.match....
Private 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").Cells(Rows.Count, 7).End(3).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").[B4:B], 0) If cp = Cells(4, K) Then MsgBox "DANHMUCCAMCO" K = K + 1 End If End If Next K End Sub
ktran a écrit le 09/01/2010 à 13h12 :
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
j ai bien re-ecris comme tu me la conseille mais j ai toujours un erreur "mismatch" comme la macro arrive sur ligne : cp = application.match....
Private 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").Cells(Rows.Count, 7).End(3).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").[B4:B], 0)
If cp = Cells(4, K) Then
MsgBox "DANHMUCCAMCO"
K = K + 1
End If
End If
Next K
End Sub
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
j ai bien re-ecris comme tu me la conseille mais j ai toujours un erreur "mismatch" comme la macro arrive sur ligne : cp = application.match....
Private 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").Cells(Rows.Count, 7).End(3).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").[B4:B], 0) If cp = Cells(4, K) Then MsgBox "DANHMUCCAMCO" K = K + 1 End If End If Next K End Sub