concaténation puis recherche de chaine

J

jb

Guest
salut ,

J ai un probleme .J ai in formulaire composé de 3 listes déroulantes , la prmiere contenant des pays , la seconde des cereales et la troisieme des noms d operation.

Ce que je veux faire c est affecter un code a chaque valeur sélectionnee dans les listes exemple ( si argentine selectionnée on créé une chaine AR , si maîs selectionne ion créé une chaine MA , et si syocks selectionné on créé une chaine st).

Une fois ceci fait , ce que je veux c est concatener les chaines créées ( exemple : ST+MA+AR pour stocks mais argentine) et rechercher cette chaine dans ma feuille excel qui est fait le nom d une serie de donnée.

Un fois cette chaine trouvée je veux creer un graphe avec les valeurs de cette série.

voila merci
je vous donne mopn code pour vous aider a mieux comprendre.

Public Sub ComboBox2_Change()
Dim cer As String
If ComboBox2.Value = "blé" Then
cer = "BL"
End If
If ComboBox2.Value = "maîs" Then
cer = "MA"
End If
If ComboBox2.Value = "orge" Then
cer = "OR"
End If
End Sub

Public Sub ComboBox3_Change()
Dim op As String
If ComboBox2.Value = "surfaces semées" Then
op = "SS"
End If
If ComboBox2.Value = "rendements" Then
op = "RR"
End If

If ComboBox2.Value = "quantité produite" Then
op = "QP"
End If

If ComboBox2.Value = "consommation fourragère" Then
op = "UA"
End If

If ComboBox2.Value = "consommation non fourragère" Then
op = "UHAH"
End If

If ComboBox2.Value = "consommation" Then
op = "UT"
End If

If ComboBox2.Value = "stocks" Then
op = "ST"
End If

If ComboBox2.Value = "échanges" Then
op = "EXN"
End If

If ComboBox2.Value = "indice de prix" Then
op = "IPV"
End If


End Sub

Public Sub CommandButton1_Click()


'Dim MaPlage As Range
Dim ident As String
'Dim identsim As String
'taille = 55
'Dim x As Long
ident = "cer"
'ident = "op" & "cer" & "pays"
'identsim = "op" & "cer" & "pays" & "F0"
'Set MaPlage = Excel.Range(Cells(1, 1), Cells(10, taille))
'For i = 1 To MaPlage.Columns.Count - 1
'If MaPlage.Item(1, i).Value = "identsim" Then
'x = i
'Exit For
'End If
'Next i
'MaPlage.Item(1, i).Select
MsgBox "& ident"


End Sub

Public Sub userform_initialize()
ComboBox1.AddItem "argentine"
ComboBox2.AddItem "blé"
ComboBox2.AddItem "maïs"
ComboBox2.AddItem "orge"
ComboBox3.AddItem "surfaces semées"
ComboBox3.AddItem "rendements"
ComboBox3.AddItem "quantité produite"
ComboBox3.AddItem "consommation fourragère"
ComboBox3.AddItem "consommation non fourragère"
ComboBox3.AddItem "consommation"
ComboBox3.AddItem "stocks"
ComboBox3.AddItem "échanges"
ComboBox3.AddItem "indices de prix"


End Sub

Public Sub ComboBox1_Change()
If ComboBox1.Value = "argentine" Then
Dim pays As String
pays = "AR"
End If

End Sub
 
S

Seb

Guest
Salut,
je suis débutant (1 semaine de vba) mais je vais essayer de t'aider...
'ident = "op" & "cer" & "pays"
'identsim = "op" & "cer" & "pays" & "F0"
mais
'ident = op & cer & pays
'identsim = op & cer & pays & F0
sinon ça concatène "op" "cer" "pays" et pas leur valeur donc ça donne "opcerpays".

Pour rechercher :
With Worksheets("nomDeLaFeuille")
Set Cel = .UsedRange.Find("CeQueTuCherches", MatchCase:=False)
End With
If Not Cel Is Nothing Then 'si la valeur a été trouvé : Cel = cellule où il y a ta valeur

Mais ce que j'ai dit, c'est pas garanti...
 

Discussions similaires

Statistiques des forums

Discussions
312 334
Messages
2 087 382
Membres
103 530
dernier inscrit
dieubrice