Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Anzeige
Inhaltsverzeichnis

Case ohne Select Case

Forumthread: Case ohne Select Case

Case ohne Select Case
17.03.2021 18:11:43
Boris
Bei folgenden Code bekomme ich die Fehlermeldung "Case ohne Select Case". Wo liegt mein Problem? Ich möchte halt jedes Mal, wenn der Case den Wert "2" annimmt, dass ein weiteres Kriterium dahingehend untersucht wird was der entsprechende Wert für "a", "b" oder "c" ist
If InStr(WS_Source.Cells(PN_out_row, 2).Value, Appl) = 0 Then
MsgBox ("Outgoing Application Code does not fit with Outgoing P/N")
Else
Select Case a
Case 1
If InStr(WS_Sub1.Cells(PN_Sub1_row, 2).Value, Appl) = 0 Then
MsgBox ("Outgoing Application Code does not fit P/N of " & Sub1)
Case 2
Select Case b
Case 1
If InStr(WS_Sub2.Cells(PN_Sub2_row, 2).Value, Appl) = 0 Then
MsgBox ("Outgoing Application Code does not fit P/N of " & Sub2)
Case 2
Select Case c
Case 1
If InStr(WS_Sub2.Cells(PN_Sub3_row, 2).Value, Appl) = 0 Then
MsgBox ("Outgoing Application Code does not fit P/N of " & Sub3)
Case 2
End Select
End Select
End Select
Exit Sub
End If

Anzeige

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Case ohne Select Case
17.03.2021 18:15:58
Hajo_Zi
arbeite mit Einrückungen dann fällt auf was falsch ist.
Option Explicit
Sub n()
If InStr(WS_Source.Cells(PN_out_row, 2).Value, Appl) = 0 Then
MsgBox ("Outgoing Application Code does not fit with Outgoing P/N")
Else
Select Case a
Case 1
If InStr(WS_Sub1.Cells(PN_Sub1_row, 2).Value, Appl) = 0 Then
MsgBox ("Outgoing Application Code does not fit P/N of " & Sub1)
Case 2
Select Case b
Case 1
If InStr(WS_Sub2.Cells(PN_Sub2_row, 2).Value, Appl) = 0 Then
MsgBox ("Outgoing Application Code does not fit P/N of " & Sub2)
Case 2
Select Case C
Case 1
If InStr(WS_Sub2.Cells(PN_Sub3_row, 2).Value, Appl) = 0 Then
MsgBox ("Outgoing Application Code does not fit P/N of " &  _
Sub3)
Case 2
End Select
End Select
End Select
Exit Sub
End If
End Sub
Bild
Homepage

Anzeige
AW: Case ohne Select Case
17.03.2021 19:13:53
Luschi
Hallo Boris,
solche Fehlinterpretationen des Compilers, wo der Fehler genau auftritt, sind Typisch, wenn man die Vba-Syntax nicht einhält. Hier fehlen beiu den If-Konstrukten das passende Gegenstück 'End If', und das mehrfach.
Oder Du löscht im Code den Zeilenwechsel nach 'End If', z.B::
If ... Then MsgBox ...
Gruß von Luschi
aus klein-Paris
Anzeige
Anzeige
Anzeige
Live-Forum - Die aktuellen Beiträge
Datum
Titel
14.05.2026 13:31:09
14.05.2026 09:50:42
13.05.2026 19:14:18