Gruppe
Allgemein
Problem
Ich möchte die letzte nichtleere Zelle in einer anderen Spalte ermitteln. Wie mache ich das?
StandardModule: basMain
Sub LastCell()
Dim rng As Range
Dim vCol As Variant
vCol = Application.InputBox( _
prompt:="Bitte Spalte als Zahl angeben:", _
Default:=2, _
Type:=1)
If vCol = "" Then Exit Sub
Set rng = Cells(Rows.Count, CInt(vCol)).End(xlUp)
If IsEmpty(rng) Then
MsgBox "Keine Zelle mit Inhalt in Spalte " & vCol & "!"
Else
Range("A1") = rng.Address(False, False)
End If
End Sub