Ich möchte in einem Visual Basic Programm
die erste leere Zelle A(n) der Spalte A finden,
so nach der Methode:
Nr =1
Testen:
If not emptycell (A(n))
Nr=Nr + 1
Goto Testen
End If
MsgBox ("Nr")
Wie lautet der Code korrekt?
Gruß Schwipp
Public Sub Erste_freie_Zelle()
Dim loLetzte As Long
With Worksheets("Tabelle1") 'Blattname anpassen
loLetzte = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
MsgBox "Die erste freie Zeile ist " & loLetzte
End With
End Sub
Gruß WernerPublic Sub Erste_freie_Zelle()
Dim loLetzte As Long
loLetzte = Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Row
MsgBox "Die erste freie Zeile ist " & loLetzte
End Sub
Beachte hierbei, dass vor dem Cells und vor dem Rows.Count dann keine Punkte sein dürfen.Option Explicit
Sub Schwipp()
Dim nR&
If Application.WorksheetFunction.CountBlank(Columns(1)) = 0 Then
MsgBox "keine leere Zelle gefunden": Exit Sub 'Spalte(1)
End If
nR = 1
Testen:
If Not IsEmpty(Cells(nR, 1)) Then
nR = nR + 1
GoTo Testen
End If
MsgBox "Nr: " & nR
End Sub
Sub ML()
Dim FreeCell&
If Application.WorksheetFunction.CountBlank(Columns(1)) = 0 Then
MsgBox "keine leere Zelle gefunden": Exit Sub
End If
FreeCell = 1
Do While Cells(FreeCell, 1) ""
FreeCell = FreeCell + 1
Loop
MsgBox "Die erste freie Zeile ist " & FreeCell
End Sub
Gruß MatthiasMsgBox Cells(1, 1).CurrentRegion.Rows.Count + 1
MsgBox 1 + WorksheetFunction.CountA(Columns(1))