Qualificateur incorrect sur un offset apres une methode find
bonjour a tous, ::coucou:
Je viens a vous pour une histoire de syntaxe.
Je souhaite obtenir la valeur de la cellule a cote d'une autre( elle trouve par la method find)
J'ai essaye un offset mais VBA n'apprecie pas et affiche:
Citation:
Erreur de compilation, qualificateur incorrect
Pouvez-vous me donner une piste?:calim2:
:merci:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| Private Sub ComboBox1_Change() 'Define action whem you select a Dealer Code
'1/ Define elements:
Dim Trouve As Range, PlageDeRecherche As Range
Dim Valeur_Cherchee As String, AdresseTrouvee As String
Dim Dealer_code As String
'2/ assigning values to variables:
'a/ Reserch Dealer code...
Valeur_Cherchee = ComboBox1.Value
'b/ ...In second columns in sheet called "2014 &projection"
Set PlageDeRecherche = Sheets("2014 &projection").Columns(2)
'3/Find method with exact value,(LookAt:=xlWhole)
Set Trouve = PlageDeRecherche.Cells.Find(what:=Valeur_Cherchee, LookAt:=xlWhole)
'4/Processing the possible error : If nothing is found:
If Trouve Is Nothing Then
'a/ value isnot found:
AdresseTrouvee = Valeur_Cherchee & " n'est pas présent dans " & PlageDeRecherche.Address
Else
'b/value is found
AdresseTrouvee = Trouve.Address
End If
'5/select the Dealer name
Dealer_code = Range(AdresseTrouvee).Offset(0, -1).Value
MsgBox Dealer_code
'6/ reset variable
Set PlageDeRecherche = Nothing
Set Trouve = Nothing
End Sub |