Formule rechercheV buggée et run macro très long

osishame

XLDnaute Junior
Bonjour,

A l'aide d'une macro "CommunsCode", je compare les premières colonnes de deux tableaux F1 (onglet BE) et F2 (onglet Crapull) et en extrait les lignes communes à partir de mon tableau F2.
Je souhaite ensuite faire une recherchev des autres colonnes de mon tableaux F2 sur mon tableau F1 pour en comparer les valeurs.

La macro tourne sans problèmes sauf sur une des colonnes "#VALUES". Help !!
Ci-joint le fichier contenant la macro et le bug surligné en rouge.

De plus, mon fichier original contient un très grand nombre de lignes (+2000) et la macro mets +de 3min à tourner. Est-il possible d'alléger mon code pour permettre un run plus performant ?

Merci :)
 

Pièces jointes

  • Macro_D.xlsm
    872.5 KB · Affichages: 226

BOISGONTIER

XLDnaute Barbatruc
Repose en paix
Re : Formule rechercheV buggée et run macro très long

=RechvSansAccent(A2;BE!$A$2:$D$11;4)

Il faut récupérer les infos des 2 fichiers directement (voir exemple joint)

Code:
Sub CommunsTot()
  Set f1 = Sheets("BD1")
  Set f2 = Sheets("BD2")
  Set f3 = Sheets("Communs2")
  Set mondico1 = CreateObject("Scripting.Dictionary")
  For Each c In f1.Range("a2:a" & f1.[a65000].End(xlUp).Row)   ' adapter
    mondico1(UCase(sansAccent(c.Value))) = c.Row
  Next c
  Set mondico2 = CreateObject("Scripting.Dictionary")
  For Each c In f2.Range("a2:a" & f2.[a65000].End(xlUp).Row)   ' adapter
    tmp = UCase(sansAccent(c.Value))
    If mondico1.exists(tmp) Then If Not mondico2.exists(tmp) Then mondico2(tmp) = c.Row
  Next c
  f3.[A2].Resize(mondico2.Count, 1) = Application.Transpose(mondico2.keys)
  col1 = f1.[A1].CurrentRegion.Columns.Count     ' adapter
  col2 = f2.[A1].CurrentRegion.Columns.Count     ' adapter
  lig = 2
  For Each c In mondico2
    f1.Cells(mondico1(c), 1).Resize(, col1).Copy f3.Cells(lig, 2)
    f2.Cells(mondico2(c), 1).Resize(, col2).Copy f3.Cells(lig, col1 + 2)
    lig = lig + 1
  Next c
End Sub

JB
 

Pièces jointes

  • Copie de Macro_D.zip
    353.7 KB · Affichages: 49
  • BDdiff.xls
    123 KB · Affichages: 44
  • BDdiff.xls
    123 KB · Affichages: 46
  • BDdiff.xls
    123 KB · Affichages: 42
Dernière édition:

Membres actuellement en ligne

Aucun membre en ligne actuellement.

Statistiques des forums

Discussions
312 506
Messages
2 089 072
Membres
104 020
dernier inscrit
Mzghal