Modif de macro

C

Chaps

Guest
oops voilà la pièce jointe dslé
 
C

chaps

Guest
grrrrrr, bon à l'ancienne alors :

Private Sub CommandButton2_Click()
If Controls('textbox1') = '' Or Controls('textbox2') = '' Or Controls('textbox3') = '' Or Controls('textbox4') = '' Or Controls('combobox1') = '' Then
MsgBox 'Saisie invalide, tous les champs doivent être renseignés', vbExclamation, 'Erreur.... Saisie incomplète !'
Controls('textbox1').SetFocus
Exit Sub
End If
[B1] = UserForm1.TextBox1
[B2] = UserForm1.TextBox2
[B3] = UserForm1.ComboBox1
[B4] = UserForm1.TextBox3
[B5] = UserForm1.TextBox4
if [B4]<[B5] then
Msgbox 'PB saisie, N° Pièce Fin < 'N° Pièce Début', vbExclamation, 'Erreur.... Saisie N° Pièce !'
end if
Géné_Export
Export_factures
MsgBox ('Procédure achevée avec succès, fichier c:\\export.txt généré')
End Sub
 
C

Chaps

Guest
Euh oui merci, j'avais compris ca mais je n'arrive pas à faire suivre deux if l'un après l'autre. Ma premiere condition est ok mais la deuxieme n'est pas prise en compte. Dois je utiliser else ou autres, j'c pas je début moi :( j'ai besoin d'un exemple avec deux conditions ou plus..

Merci
 

ERIC S

XLDnaute Barbatruc
re

tout dépend de ce que tu veux :

1/ b4 inf B5 et b1 inf b2

if b4 inf b5 and b& inf b2 then
...
end if

2/ b4 inf b5 ou b1 inf b2

if b4 inf b5 or b1 inf b2 then
...
end if

3/ indépendantes

if b4 inf b5 then
...
end if
if b1 inf b2 then
...
end if

4/ si b4 inf b5 alors si b1 inf b2 sinon

if b4 inf b5 then
if b1 inf b2 then
...
else
...
end if
end if

A toi de choisir

A+
 
C

Chaps

Guest
Re,

Dans le cas ou j'obtiens le message d'erreur pour la comparaison de mes deux cellules comment faire pour ne pas lancer les macros qui suivent et devoir donc resaissir correctement les cellules fausses via l'userform bien sur.

J'en demande bcp je c :(
 

ERIC S

XLDnaute Barbatruc
re

essaie de tester avant d'écrire sur la feuille


Private Sub CommandButton2_Click()
If Controls(\\'textbox1\\') = \\'\\' Or Controls(\\'textbox2\\') = \\'\\' Or Controls(\\'textbox3\\') = \\'\\'
Or Controls(\\'textbox4\\') = \\'\\' Or Controls(\\'combobox1\\') = \\'\\' Then
MsgBox \\'Saisie invalide, tous les champs doivent être renseignés\\', vbExclamation, \\'Erreur....
Saisie incomplète !\\'
Controls('textbox1').SetFocus
Exit Sub
End If

if UserForm1.TextBox3 < UserForm1.TextBox4
Msgbox \\'PB saisie, N° Pièce Fin < \\'N° Pièce Début\\', vbExclamation, \\'Erreur.... Saisie N°
Pièce !\\'
Controls('textbox3').SetFocus
Exit Sub
End If

[B1] = UserForm1.TextBox1
[B2] = UserForm1.TextBox2
[B3] = UserForm1.ComboBox1
[B4] = UserForm1.TextBox3
[B5] = UserForm1.TextBox4

Géné_Export
Export_factures
MsgBox ('Procédure achevée avec succès, fichier c:export.txt généré')
End Sub
 
C

Chaps

Guest
Re,

Dslé, et si je souhaite un comparatif sur des dates, je veux dire imaginons que

if userform1.textbox3 < userform1.textbox4

avec donc des dates, apres test ca passe pas normal?

si methode merci de me l enseigner
:evil:

Chaps
 

ERIC S

XLDnaute Barbatruc
re

il me faudrait plus de précision mais regarde

1/ dans tes tests

if not isdate(UserForm1.TextBox3) or not isdate(UserForm1.TextBox4) then
msgbox 'pb date'
Controls('textbox3').SetFocus
Exit Sub
End If

sinon après essaie

if cdate(UserForm1.TextBox3)<cdate(UserForm1.TextBox4) then
...
end if

et en écriture


B4] = format(UserForm1.TextBox3,'dd/mm/yyyy')

A+
 

Statistiques des forums

Discussions
312 697
Messages
2 091 077
Membres
104 753
dernier inscrit
FLIS