AW: Automatisches Auffüllen Zellen
13.11.2009 13:02:31
David
Hallo Robert,
hier eine Variante, die ich selbst verwendet, mit variabler Eingabe des betreffendes Bereichs:
Sub fill_lines()
Dim first_line As Integer
Dim last_line As Integer
Dim spalte_AN As String
Dim spalte_BN As String
Dim spalte_N As Byte
Dim spalte_O As Byte
first_line = CInt(0 & InputBox("erste Zeile?", , 2))
last_line = CInt(0 & InputBox("letzte Zeile?", , ActiveSheet.UsedRange.Rows.Count))
spalte_AN = InputBox("Spalte von?", , "a")
spalte_BN = InputBox("Spalte bis?", , "a")
If first_line 64 Then
spalte_N = spalte_N - 64
ElseIf spalte_N 96 Then
spalte_N = spalte_N - 96
Else:
MsgBox ("falsche Eingabe, nur Buchstaben von A-Z (a-z) erlaubt")
Exit Sub
End If
spalte_O = Asc(spalte_BN)
If spalte_O 64 Then
spalte_O = spalte_O - 64
ElseIf spalte_O 96 Then
spalte_O = spalte_O - 96
Else:
MsgBox ("falsche Eingabe, nur Buchstaben von A-Z (a-z) erlaubt")
Exit Sub
End If
For Zeile = first_line To last_line
For Spalte = spalte_N To spalte_O
'Cells(Zeile, spalte_N).Select
If Cells(Zeile, Spalte).Value = "" Then
Cells(Zeile, Spalte).Value = Cells(Zeile - 1, Spalte).Value
End If
Next
Next
End Sub
Im Unterschied zur Variante von Petra werden hier die Leerzellen mit dem tatsächlichen Wert gefüllt und nicht mit dem Verweis auf die vorherige Zelle (also einer Formel).
Gruß
David