H
hoa
Guest
Bonsoir à tous
voici une macro que j'utilise depuis longtemps
Elle permet de comparer deux colonnes de deux feuilles d'un même classeur
Cette colonne est alimentée par des codes correspondant à des articles de la feuille bibliothèque
Le problème pour moi c'est que la bibliothèque (feuil2) se trouve dans le même fichier.
Comment inséré un chemin pour feuil2 (bibliothèque) dans un autre classeur et dans un lieu précis ?
Je vous remercie par avance pour vos idées.
Sub Bilbliotheque()
'Plage("C15").Sélectionner
'CelluleActive.FormuleL1C1 = "s"
'Plage("C16").Sélectionner
Dim CelluleBiblio As Variant
Dim CelluleEtude As Variant
Dim ValTrouve As Integer
'Pour la feuille Etude (Max 2500 Lignes)
For IndiceEtude = 11 To 2500
CelluleEtude = "A"
CelluleEtude = CelluleEtude + LTrim(Str(IndiceEtude))
If (Feuil1.Range(CelluleEtude).Value = "fin") Then Exit For
If (Feuil1.Range(CelluleEtude).Value = "") Then GoTo FinFor
' Pour la feuille bibliothèque(10 = premiere ligne, 1000 = derniere ligne
ValTrouve = 0
IndiceBiblio = 10
Do
CelluleBiblio = "A"
CelluleBiblio = CelluleBiblio + LTrim(Str(IndiceBiblio))
' Si on trouve le code dans la bibliotheqe, on quitte la boucle
If (Feuil2.Range(CelluleBiblio).Formula = Feuil1.Range(CelluleEtude).Formula) Then ValTrouve = 1
If (Feuil2.Range(CelluleBiblio).Formula = Feuil1.Range(CelluleEtude).Formula) Then Exit Do
IndiceBiblio = IndiceBiblio + 1
Loop While (Feuil2.Range(CelluleBiblio).Formula <> "")
If (ValTrouve = 0) Then MsgBox ("Pas Trouve : " + Feuil1.Range(CelluleEtude).Formula)
If (ValTrouve = 0) Then GoTo FinFor
For IndiceColonne = 7 To 120
If (Feuil2.Cells(IndiceBiblio, IndiceColonne).Value <> "*") Then Feuil1.Cells(IndiceEtude, IndiceColonne).Formula = Feuil2.Cells(IndiceBiblio, IndiceColonne).Formula
Next
FinFor:
Next
Feuil1.Calculate
End Sub
voici une macro que j'utilise depuis longtemps
Elle permet de comparer deux colonnes de deux feuilles d'un même classeur
Cette colonne est alimentée par des codes correspondant à des articles de la feuille bibliothèque
Le problème pour moi c'est que la bibliothèque (feuil2) se trouve dans le même fichier.
Comment inséré un chemin pour feuil2 (bibliothèque) dans un autre classeur et dans un lieu précis ?
Je vous remercie par avance pour vos idées.
Sub Bilbliotheque()
'Plage("C15").Sélectionner
'CelluleActive.FormuleL1C1 = "s"
'Plage("C16").Sélectionner
Dim CelluleBiblio As Variant
Dim CelluleEtude As Variant
Dim ValTrouve As Integer
'Pour la feuille Etude (Max 2500 Lignes)
For IndiceEtude = 11 To 2500
CelluleEtude = "A"
CelluleEtude = CelluleEtude + LTrim(Str(IndiceEtude))
If (Feuil1.Range(CelluleEtude).Value = "fin") Then Exit For
If (Feuil1.Range(CelluleEtude).Value = "") Then GoTo FinFor
' Pour la feuille bibliothèque(10 = premiere ligne, 1000 = derniere ligne
ValTrouve = 0
IndiceBiblio = 10
Do
CelluleBiblio = "A"
CelluleBiblio = CelluleBiblio + LTrim(Str(IndiceBiblio))
' Si on trouve le code dans la bibliotheqe, on quitte la boucle
If (Feuil2.Range(CelluleBiblio).Formula = Feuil1.Range(CelluleEtude).Formula) Then ValTrouve = 1
If (Feuil2.Range(CelluleBiblio).Formula = Feuil1.Range(CelluleEtude).Formula) Then Exit Do
IndiceBiblio = IndiceBiblio + 1
Loop While (Feuil2.Range(CelluleBiblio).Formula <> "")
If (ValTrouve = 0) Then MsgBox ("Pas Trouve : " + Feuil1.Range(CelluleEtude).Formula)
If (ValTrouve = 0) Then GoTo FinFor
For IndiceColonne = 7 To 120
If (Feuil2.Cells(IndiceBiblio, IndiceColonne).Value <> "*") Then Feuil1.Cells(IndiceEtude, IndiceColonne).Formula = Feuil2.Cells(IndiceBiblio, IndiceColonne).Formula
Next
FinFor:
Next
Feuil1.Calculate
End Sub