A | B | C | D | E | |
---|---|---|---|---|---|
1 | Beispiel A | ||||
2 | |||||
3 | |||||
4 | Beispiel B | ||||
5 | |||||
6 | |||||
7 | |||||
8 | Beispiel C | ||||
9 | |||||
10 |
A | B | C | D | E | |
---|---|---|---|---|---|
1 | Beispiel A | ||||
2 | Beispiel A | ||||
3 | Beispiel A | ||||
4 | Beispiel B | ||||
5 | Beispiel B | ||||
6 | Beispiel B | ||||
7 | Beispiel B | ||||
8 | Beispiel C | ||||
9 | Beispiel C | ||||
10 | Beispiel C |
Option Explicit
' ****************************************************************
' Autor/en und Original-Quelltext unter:
' https://www.online-vba.de/vba_zsvervoll.php
' Verwendung der Quelltexte auf eigene Gefahr!
' Es gelten die Nutzungsbedingungen von https://www.online-vba.de
' ****************************************************************
Public Sub OVBAde_ZeilenNachUntenVervollstaendigen()
Dim oRow As Object
For Each oRow In Selection.Rows
If Trim(CStr(Cells(oRow.Row, Selection.Column).Value)) = "" And oRow.Row <> Selection.Row Then
Cells(oRow.Row, Selection.Column).Value = Cells(oRow.Row - 1, Selection.Column).Value
End If
Next oRow
Set oRow = Nothing
End Sub
Public Sub OVBAde_SpaltenNachRechtsVervollstaendigen()
Dim oCol As Object
For Each oCol In Selection.Columns
If Trim(CStr(Cells(Selection.Row, oCol.Column).Value)) = "" _
And oCol.Column <> Selection.Column Then
Cells(Selection.Row, oCol.Column).Value = Cells(Selection.Row, oCol.Column - 1).Value
End If
Next oCol
Set oCol = Nothing
End Sub