Oder wie sag ich in VBA das der zeiger eine Zeile tiefer springen soll?
MfG Easyrider
Sub Rand_letzter_Eintrag()
'funktioniert für Neueinträge, die an das Ende der Liste angefügt werden:
Dim Znr, Spnr As Integer
Dim b, i, n As Long
b = 2 '= Zeile für 1. Eintrag
n = 65536 '= letzte Zeile
Spnr = 4 'z.Bsp.:
'Randformatierung soll bis Spalte "D" gesetzt werden
For i = 2 To n
If Cells(i, 1).Value = "" Then '= 1. leere Zeile
Znr = i - 1 '= Zeile(letzter Eintrag)
ActiveSheet.Range(Cells(Znr, 1), Cells(Znr, Spnr)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlDot
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlDot
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlDot
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlDot
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlDot
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Exit Sub
End If
Next i
End Sub