Live-Forum - Die aktuellen Beiträge
Datum
Titel
17.04.2024 18:57:33
17.04.2024 16:56:58
Anzeige
Archiv - Navigation
748to752
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
748to752
748to752
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Else ohne If Block

Else ohne If Block
27.03.2006 12:34:04
Josef
Hallo!
Ich bekomme bei unten stehendem Code den Fehlehinweis Else ohne If Block.
Ich habe jedoch einen If Block.
Wo liege ich hier bitte falsch?
Danke
Josef

Private Sub CommandButton2_Click()
If CheckBox1.Value = False Then
If CheckBox3.Value = False Then GoTo WEITER
If CheckBox5.Value = False Then GoTo WEITER
If CheckBox7.Value = False Then GoTo WEITER
If CheckBox9.Value = False Then GoTo WEITER
If CheckBox11.Value = False Then GoTo WEITER
If CheckBox13.Value = False Then GoTo WEITER
If CheckBox15.Value = False Then GoTo WEITER
If CheckBox17.Value = False Then GoTo WEITER
If CheckBox19.Value = False Then GoTo WEITER
If CheckBox21.Value = False Then GoTo WEITER
If CheckBox23.Value = False Then GoTo WEITER
End If
Else
Dim rngFind As Range
Dim intCount As Integer, intCol As Integer, lngRow As Long
If Not IsDate(datumtxt1) Then Exit Sub
With ActiveSheet
Set rngFind = .Range("B:B").Find(What:=CDate(datumtxt1), LookAt:=xlWhole, LookIn:=xlFormulas)
If Not rngFind Is Nothing Then
lngRow = rngFind.Row
intCol = 26
For intCount = 1 To 23
Select Case intCount
Case 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23
'If Controls("CheckBox" & intCount) > 0 Then
If Len(Trim$(Controls("CheckBox" & intCount))) > 0 Then
If IsNumeric(Controls("CheckBox" & intCount)) Then
'.Cells(lngRow, intCol) = CSng(Controls("CheckBox" & intCount))
.Cells(lngRow, intCol) = Abs(CDbl(Controls("CheckBox" & intCount)))
Else
.Cells(lngRow, intCol) = Controls("CheckBox" & intCount)
End If
End If
intCol = intCol + 1
Case Else
lngRow = lngRow + 1
intCol = 26
End Select
Next
End If
Set rngFind = Nothing
End With
End If
WEITER:
Exit Sub
End Sub

4
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Else ohne If Block
27.03.2006 12:41:42
Uwe
Hi Josef,
das Else muss (incl. der folgenden Zeilen) vor dem End If, also innerhalb der Bedingung stehen.
War das der Fehler?
Gruß
Uwe
(:o)
AW: Else ohne If Block
27.03.2006 13:01:15
UweD
Hallo
wenn du es so stuktoriert darstellst fällt es auf.
Siehe die markierte Stelle. das End If ist dort zu viel.


      
Private Sub CommandButton2_Click()
    
If CheckBox1.Value = False Then
        
If CheckBox3.Value = False Then GoTo WEITER
        
If CheckBox5.Value = False Then GoTo WEITER
        
If CheckBox7.Value = False Then GoTo WEITER
        
If CheckBox9.Value = False Then GoTo WEITER
        
If CheckBox11.Value = False Then GoTo WEITER
        
If CheckBox13.Value = False Then GoTo WEITER
        
If CheckBox15.Value = False Then GoTo WEITER
        
If CheckBox17.Value = False Then GoTo WEITER
        
If CheckBox19.Value = False Then GoTo WEITER
        
If CheckBox21.Value = False Then GoTo WEITER
        
If CheckBox23.Value = False Then GoTo WEITER
    
'End If  ******Das hier ist zu viel
    Else
        
Dim rngFind As Range
        
Dim intCount As Integer, intCol As Integer, lngRow As Long
        
If Not IsDate(datumtxt1) Then Exit Sub
        
With ActiveSheet
            
Set rngFind = .Range("B:B").Find(What:=CDate(datumtxt1), LookAt:=xlWhole, LookIn:=xlFormulas)
            
If Not rngFind Is Nothing Then
                lngRow = rngFind.Row
                intCol = 26
                
For intCount = 1 To 23
                    
Select Case intCount
                        
Case 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23
                            
'If Controls("CheckBox" & intCount) > 0 Then
                            If Len(Trim$(Controls("CheckBox" & intCount))) > 0 Then
                                
If IsNumeric(Controls("CheckBox" & intCount)) Then
                                    
'.Cells(lngRow, intCol) = CSng(Controls("CheckBox" & intCount))
                                    .Cells(lngRow, intCol) = Abs(CDbl(Controls("CheckBox" & intCount)))
                                
Else
                                    .Cells(lngRow, intCol) = Controls(
"CheckBox" & intCount)
                                
End If
                            
End If
                            intCol = intCol + 1
                        
Case Else
                            lngRow = lngRow + 1
                            intCol = 26
                    
End Select
                
Next
            
End If
            
Set rngFind = Nothing
        
End With
    
End If
WEITER:
End Sub 


außerdem kann das Exit Sub weg
Gruß UweD
(Rückmeldung wäre schön)
Anzeige
AW: Else ohne If Block
27.03.2006 12:53:41
Harald
Hi,
lass mal das End If vor dem Else ganz weg
Gruss Harald
DANKE an alle
28.03.2006 06:11:51
Josef
Besten Dank an Euch für Eure Hilfe.
Josef

212 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige