Wie schaffe ich es über VBA, dass excel sich die Anzahl eingefügter Zellen merkt und markiert.
Zur Erläuterung:
Über eine InputBox habe ich mir die Möglichkeit geschaffen, die Anzahl von einzufügenden Zeilen einzugeben. Die Tabelle hat 22 Spalten (A bis V). Wenn ich nun die Zeilen eingefügt habe, sollen genau dies noch formatiert werden. Um was muss der unten aufgeführte Programmcode erweitert werden, damit die Zellen von Spalte A bis Spalte V der neuen Zeilen markiert werden?
Sub ZeilenEinfuegen()
Dim iCount As Integer
On Error Resume Next
iCount = InputBox("Anzahl der Zeilen:")
If iCount = vbCancel Then
ActiveSheet.Range("A5:A" & Cells(Rows.Count, 1).End(xlUp).Row).Select
ActiveCell.Offset(1, 0).Select
With Selection
Rows(ActiveCell.Row + iCount & ":" & _
.Row + (iCount * 0) + 1).Rows.Insert
Range(ActiveCell, ActiveCell.Offset(0, 21)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
ActiveWindow.LargeScroll ToRight:=-1
End With
Else
Exit Sub
End If
End
Danke im voraus
Dirk