Re bonjour,
Je n'arrive pas a adapté une macro que j'utilise déjà pour une recherche,
Voir fichier joint,
Pour la macro qui fonction le principe est le suivant sur un tableau je rempli les numéro de devis, sur un autre les numéro de plan la macro effectue une recherche en fonction du numéro de devis et affiche dans une cellule le numéro de plan corespondant.
Je souhaiterai reprendre le meme procédé mais cette fois ci faire la recherche en fonction du numéro de dossier.
dans la case ou se trouve les numero de plan j'ai mis la formule
=SI(B27="";findplan(A27);findplan2(A27))
Mais je n'arrive pas a creer la fonction findplan2
La macro que j'ai ecrite est la suivante :
Option Explicit
Function findplan(numdevis)
Application.Volatile ' rend la mise a jour de la fonction continue
Dim DerLig As Long, Lig As Long, VPlan As String
findplan = ""
With Sheets("N° PLAN")
DerLig = .Range("A" & Rows.Count).End(xlUp).Row ' recherche à la colonne A en partant de la derniere
For Lig = 2 To DerLig ' si trouvé lire colonne 2
VPlan = .Range("A" & Lig).Value
' Vérifier si le devis du plan correspond à la recherche
If CStr(.Range("B" & Lig)) = numdevis Then
findplan = findplan & VPlan & " " ' séparation des resultats trouvés
End If
Next Lig
End With
If Len(findplan) > 0 Then
' Enlever la dernière virgule
findplan = Left(findplan, Len(findplan) - 1)
End If
End Function
Celle ci marche bien
adaptation qui m'affiche dans la cellule #Valeur
Function findplan2(numdossier)
Application.Volatile ' rend la mise a jour de la fonction continue
Dim DerLig As Long, Lig As Long, VPlan As String
findplan2 = ""
With Sheets("Feuil2")
DerLig = .Range("A" & Rows.Count).End(xlUp).Row
For Lig = 2 To DerLig
VPlan = .Range("A" & Lig).Value
' Vérifier si le devis du plan correspond à la recherche
If CStr(.Range("C" & Lig)) = numdossier Then
findplan2 = findplan2 & VPlan & " " & "/" & " "
End If
Next Lig
End With
If Len(findplan2) > 0 Then
' Enlever la dernière virgule
findplan2 = Left(findplan2, Len(findplan2) - 1)
End If
End Function
J'espere avoir été claire dans mon probleme.
Merci a vous
Je n'arrive pas a adapté une macro que j'utilise déjà pour une recherche,
Voir fichier joint,
Pour la macro qui fonction le principe est le suivant sur un tableau je rempli les numéro de devis, sur un autre les numéro de plan la macro effectue une recherche en fonction du numéro de devis et affiche dans une cellule le numéro de plan corespondant.
Je souhaiterai reprendre le meme procédé mais cette fois ci faire la recherche en fonction du numéro de dossier.
dans la case ou se trouve les numero de plan j'ai mis la formule
=SI(B27="";findplan(A27);findplan2(A27))
Mais je n'arrive pas a creer la fonction findplan2
La macro que j'ai ecrite est la suivante :
Option Explicit
Function findplan(numdevis)
Application.Volatile ' rend la mise a jour de la fonction continue
Dim DerLig As Long, Lig As Long, VPlan As String
findplan = ""
With Sheets("N° PLAN")
DerLig = .Range("A" & Rows.Count).End(xlUp).Row ' recherche à la colonne A en partant de la derniere
For Lig = 2 To DerLig ' si trouvé lire colonne 2
VPlan = .Range("A" & Lig).Value
' Vérifier si le devis du plan correspond à la recherche
If CStr(.Range("B" & Lig)) = numdevis Then
findplan = findplan & VPlan & " " ' séparation des resultats trouvés
End If
Next Lig
End With
If Len(findplan) > 0 Then
' Enlever la dernière virgule
findplan = Left(findplan, Len(findplan) - 1)
End If
End Function
Celle ci marche bien
adaptation qui m'affiche dans la cellule #Valeur
Function findplan2(numdossier)
Application.Volatile ' rend la mise a jour de la fonction continue
Dim DerLig As Long, Lig As Long, VPlan As String
findplan2 = ""
With Sheets("Feuil2")
DerLig = .Range("A" & Rows.Count).End(xlUp).Row
For Lig = 2 To DerLig
VPlan = .Range("A" & Lig).Value
' Vérifier si le devis du plan correspond à la recherche
If CStr(.Range("C" & Lig)) = numdossier Then
findplan2 = findplan2 & VPlan & " " & "/" & " "
End If
Next Lig
End With
If Len(findplan2) > 0 Then
' Enlever la dernière virgule
findplan2 = Left(findplan2, Len(findplan2) - 1)
End If
End Function
J'espere avoir été claire dans mon probleme.
Merci a vous