Incomptatibilité de type
Bonjour à tous. je reviens vers vous car là je ne comprend plus les raisons de ce message d'erreur. incompatibilité de type.
Mon ficher excel comprend 3 feuilles (Listing_client / Tarifs / Factures)
J'ai creer plusieurs userform pour le coté "fun" et pratique (ce n'est pas pour moi).
mon problème vient dans la saisie d'une facture. J'ai une combobox alimentée avec la feuille listing client. lors de la "selection" du fameux client, son nom, prenom, adresse alimentés la feuille facture. J'ai aussi besoin de son email pour l'envoi de la facture.
Tout marchait très bien, mais j'ai eu un souci avec la feuille listing_client et depuis plus rien ne fonctionne. Quelqu'un peut jeter un oeil ?
L'erreur intervient sur cette ligne :
emailclient.Text = Application.Index(Range("Tableau7[email]"), choixclient.Value)Voici une partie du code. et je vous envoie le fichier entier pour avoir une vue plus large. merci d'avance.
Private Sub UserForm_Initialize() 'à l'initialisation de l'userform, avant l'activation
With Me 'avec moi, l'userform
Sheets("Listing_client").Activate
.choixclient.List = Range("Tableau7").Value 'alimentation de la liste des clients
End With
End Sub
Private Sub choixclient_change() 'à chaque chgt de valeur de cbxclient
Dim ligneclt As Integer: ligneclt = 3
Dim ligneclt1 As Integer: ligneclt1 = 4
Dim ligneclt2 As Integer: ligneclt2 = 5
Dim adresse2 As String
Dim cp1 As String
Dim ville1 As String
With Me
MsgBox choixclient.Value 'affichage du client choisi
emailclient.Text = Application.Index(Range("Tableau7[email]"), choixclient.Value)
nom1 = Application.Index(Range("Tableau7[nom]"), choixclient.Value)
prenom1 = Application.Index(Range("Tableau7[prenom]"), choixclient.Value)
adresse2 = Application.Index(Range("Tableau7[adresse]"), choixclient.Value)
cp1 = Application.Index(Range("Tableau7[CP]"), choixclient.Value)
ville1 = Application.Index(Range("Tableau7[ville]"), choixclient.Value)
MsgBox ("Bonjour " & nom1 & " , " & prenom1)
ThisWorkbook.Worksheets("Facture").Cells(ligneclt, 5).Value = nom1
ThisWorkbook.Worksheets("Facture").Cells(ligneclt, 7).Value = prenom1
ThisWorkbook.Worksheets("Facture").Cells(ligneclt1, 5).Value = adresse1
ThisWorkbook.Worksheets("Facture").Cells(ligneclt2, 5).Value = cp1
ThisWorkbook.Worksheets("Facture").Cells(ligneclt2, 6).Value = ville1
End With
End SubHello,
Tout marchait très bien, mais j'ai eu un souci avec la feuille listing_client
Es - tu sur ?
Car si j'en crois l'aide en ligne de la methode Application.Index, cette méthode comporte deux arguments obligatoire, un array & un numéro de ligne.
choixclient.ValueQue contient ce code ?
Il ne contient pas un numéro de ligne mais une chaine de caractère.
Essaye comme ceci pour mon ami :
emailclient.Text = Application.Index(Range("Tableau7[email]"), 1)bah écoute, je vais testé ta methode pour voir. là j'ai un souci juste sur une boucle infinie...
je souhaite validé ma facture avec un mode de paiement (optionbutton) mais je tourne en rond car je veux pas aller plus loin dans la procédure
dans ma logique : tant que marqueur=0 alors on reverifie les optionbutton et si c'est coché, marqueur = 1 donc on sort mais boucle infinie.
Do Until marqueur < 1
Call controlereglement
LoopSub controlereglement()
'validation paiement
If CB.Value = True Then
Range("F35").Value = CB.Caption
marqueur = 2
MsgBox marqueur
Else
If monnaie.Value = True Then
Range("F35").Value = monnaie.Caption
marqueur = 2
Else
If cheque.Value = True Then
Range("F35").Value = cheque.Caption
marqueur = 2
Else
If cb_monnaie.Value = True Then
Range("F35").Value = cb_monnaie.Caption
marqueur = 2
Else
If cb_chq.Value = True Then
Range("F35").Value = cb_chq.Caption
marqueur = 2
Else
If monnaie_chq.Value = True Then
Range("F35").Value = monnaie_chq.Caption
marqueur = 2
Else
MsgBox ("Saisir un mode de réglement")
marqueur = 0
End If
End If
End If
End If
End If
End If
Wend
End SubHello,
Pour ta boucle je ne vois pas comme ça ...
Par contre tu peux utiliser cette syntaxe pour y voir + clair dans tes conditions :
if CB.Value = true
.......
elseif monnaie.value = true then
........
elseif .... then
end if& pour le 1 à la fin de :
emailclient.Text = Application.Index(Range("Tableau7[email]"), 1)c'est juste un test il faudra trouver comment remplacer le 1 par la vraie ligne de ton client
Bonsoir,
Je reviens ici car j'ai à nouveau le même souci d'incomptatibilité...
Mon fichier excel se compose toujours de 3 feuilles :
* Listing_client (qui est un tableau clientele : num / nom prénom / adresse / CP / ville / telephone / email / date naissance
* Facture (qui génère ma facture selon les prestations demandées
* Tarifs (qui regroupent sous forme de tableau l'ensemble des prestations et le prix)
Dans mon unserform j'ai une liste déroulante pour choisir mon client a facturé. Je charge de cette façon :
Private Sub UserForm_Initialize() 'à l'initialisation de l'userform, avant l'activation
With Me 'avec moi, l'userform
Sheets("Listing_client").Activate
.choixclient.List = Range("Tableau7").Value 'alimentation de la liste des clients
End With
End SubVoici le code lors d'un changement dans la liste déroulante :
Private Sub choixclient_change() 'à chaque chgt de valeur de choixclient
Dim adresse2 As Variant
Dim cp1 As Variant
Dim ville1 As Variant
Dim position As Variant
With Me
position = Application.Match(choixclient.Value, Range("Tableau7[nom prénom]"), 1) 'position dans la colonne du client sélectionné
MsgBox position
emailclient.Text = Application.Index(Range("Tableau7[email]"), position)
nom1 = Application.Index(Range("Tableau7[nom prénom]"), position)
adresse1 = Application.Index(Range("Tableau7[adresse]"), position)
cp1 = Application.Index(Range("Tableau7[CP]"), position)
ville1 = Application.Index(Range("Tableau7[ville]"), position)
'MsgBox ("Client(e) " & nom1), vbInformation, "Client"
ThisWorkbook.Worksheets("Facture").Cells(3, 5).Value = nom1
ThisWorkbook.Worksheets("Facture").Cells(4, 5).Value = adresse1
ThisWorkbook.Worksheets("Facture").Cells(5, 5).Value = cp1
ThisWorkbook.Worksheets("Facture").Cells(5, 6).Value = ville1
End With
End SubForcement j'ai encore la même erreur sur la ligne position =.....
Les propriétés du combobox choixclient sont :Columncount : 2 / ColumnWidths : 1pt;150pt
sinon j'ai rien changé.
Là je ne comprend plus. orientez moi svp.
Hello,
Post un fichier exemple ça sera + simple
ah oui pardon c'est plus simple avec le ficher. parfois ya des msgbox mais c'est a titre indicatif
Hello,
Je pense que c'est bon comme ça :
Private Sub choixclient_change() 'à chaque chgt de valeur de cbxclient
Dim adresse1 As String
Dim cp1 As String
Dim ville1 As String
Dim position As Variant
Dim nom1 As String
With Me
position = Application.Match(choixclient.Column(1), Range("Tableau7[nom prénom]"), 0) 'position dans la colonne du client sélectionné
emailclient.Text = Application.Index(Range("Tableau7[email]"), position)
nom1 = Application.Index(Range("Tableau7[nom prénom]"), position)
adresse1 = Application.Index(Range("Tableau7[adresse]"), position)
cp1 = Application.Index(Range("Tableau7[CP]"), position)
ville1 = Application.Index(Range("Tableau7[ville]"), position)
'MsgBox ("Client(e) " & nom1), vbInformation, "Client"
ThisWorkbook.Worksheets("Facture").Cells(3, 5).Value = nom1
ThisWorkbook.Worksheets("Facture").Cells(4, 5).Value = adresse1
ThisWorkbook.Worksheets("Facture").Cells(5, 5).Value = cp1
ThisWorkbook.Worksheets("Facture").Cells(5, 6).Value = ville1
End With
End Sub