Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
712to716
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
712to716
712to716
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

mehrere Befehl in if...then

mehrere Befehl in if...then
04.01.2006 22:53:02
gnilk
Hallo Leute,
mein Problem ist, dass ich einen if...then...else Code habe die nicht funktioniert. Jedoch soll eine lange Funktion nach dem then folgen. Also drei Befehle. Danach geht esdan wieder miteinerm Else If weiter. Das Problem ist jetzt, dass bei einer Else...If...Then...Else If Funktion alles in einer Zeile stehen muss. Wie loese ich mein Probem? Wer kann mir den richtigen Code nennen.
Hier mein bisheriger Code:
If OptionButton5 = True And OptionButton1 = True And CheckBox1 = False _
And CheckBox2 = False Then _
If db.Cells(pmpRow, 12) - ComboBox2 &lt 0 Then _
MsgBox "Ouantity can't be less than '0'!"
UsFr.Show
Exit Sub
Else db.Cells(pmpRow, 12) = db.Cells(pmpRow, 12) - ComboBox3 _
Else If OptionButton5 = True And OptionButton2 = True And CheckBox1 = False _
And CheckBox2 = False Then _
If db.Cells(pmpRow, 15) - ComboBox2 &lt 0 Then _
MsgBox "Ouantity can't be less than '0'!" And _
UsFr.Show
.....usw.
Vielen Dank im Voraus
ciao
Gnilk

5
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: mehrere Befehl in if...then
05.01.2006 00:12:07
KapitänNet
Hallo Gnilk,
Die If Else Verschachtelung kann so nicht stimmen.
Was du mit folgender Zeile mit Else und nachfolgendem Else If bezweckst, ist mir unklar.
Mit dem ersten Else wird der darauf folgende Befehl ausgeführt, was soll dann aber die Befehlszeilenverlängerung mit dem "_"?
Anstelle des "Else If" musst du ein ElseIf verwenden und die Zeile mit den Fragezeilen korrekt integrieren. Wenn der Else korrekt wäre, kann daruf nur ein If folgen und kein Else If.
? Else db.Cells(pmpRow, 12) = db.Cells(pmpRow, 12) - ComboBox3 _ ?
Else If OptionButton5 = True And OptionButton2 = True And CheckBox1 = False _
...
Ciao Jürgen
Anzeige
AW: mehrere Befehl in if...then
05.01.2006 00:54:22
gnilk
Hallo Juergen,
wie muss dann der Code richtig lauten? Etwa so?
If OptionButton5 = True And OptionButton1 = True And CheckBox1 = False _
And CheckBox2 = False Then
If db.Cells(pmpRow, 12) - ComboBox2 &lt 0 Then
MsgBox "Ouantity can't be less than '0'!"
UsFr.Show
Exit Sub
Else: db.Cells(pmpRow, 12) = db.Cells(pmpRow, 12) - ComboBox3
ElseIf OptionButton5 = True And OptionButton2 = True And CheckBox1 = False _
And CheckBox2 = False Then
If db.Cells(pmpRow, 15) - ComboBox2 &lt 0 Then
MsgBox "Ouantity can't be less than '0'!" And UsFr.Show
Else: db.Cells(pmpRow, 15) = db.Cells(pmpRow, 15) - ComboBox3
Wenn ja, dann funktioniert es so nicht. Ich muss den Doppelpunkt hinter dem Else wegbekommen. Schreib mir mal bitte, was Du fuer richtig halten wuerdest.
Vielen Dank im Voraus
ciao
Gnilk
Anzeige
AW: mehrere Befehl in if...then
05.01.2006 00:55:56
gnilk
Frage natuerlich noch offen
AW: mehrere Befehl in if...then
05.01.2006 10:04:31
MichaV
Hallo,
ungetestet:

Private Sub DeineVersion()
If OptionButton5 And OptionButton1 And Not CheckBox1 And Not CheckBox2 Then
If Db.Cells(pmpRow, 12) - ComboBox2 < 0 Then
MsgBox "Ouantity can't be less than '0'!"
UsFr.Show
Exit Sub
Else
Db.Cells(pmpRow, 12) = Db.Cells(pmpRow, 12) - ComboBox3
End If
ElseIf OptionButton5 And OptionButton2 And Not CheckBox1 And Not CheckBox2 Then
If Db.Cells(pmpRow, 15) - ComboBox2 < 0 Then
MsgBox "Ouantity can't be less than '0'!"
UsFr.Show
Else
Db.Cells(pmpRow, 15) = Db.Cells(pmpRow, 15) - ComboBox3
End If
End If
End Sub

Gruß- Micha
PS: Rückmeldung wäre nett.
Anzeige
AW: mehrere Befehl in if...then
09.01.2006 01:18:26
gnilk
Hallo Micha,
hat geklappt. Tausend Dank
Ciao
Gnilk

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige