innve89
innve89

Reputation: 101

Add a row or column to selection Excel

This is probably super simple but If I already have a selection how can I add the next row without know necessarily what the next one is?

EDIT For example if I have the input range "D1:D8" how can I add in the next row, ie "D1:D9" without putting in "D1:D9".

Upvotes: 2

Views: 2476

Answers (2)

iDevlop
iDevlop

Reputation: 25262

Sub test()
    Dim rng As Range
    Set rng = Range("b2:f5")
    Debug.Print rng.Address     'returns $B$2:$F$5
    Set rng = rng.Resize(rng.Rows.Count + 1)
    Debug.Print rng.Address     'returns $B$2:$F$6
End Sub

Upvotes: 2

99moorem
99moorem

Reputation: 1983

Try

Sub inc_row()
Selection.Resize(Selection.Rows.Count + 1, Selection.Columns.Count).Select
End Sub

This will increase your selection by 1 row, it will also select the new range

Upvotes: 3

Related Questions