oma2484
oma2484

Reputation: 25

excel vba can CurrentRegion give a specific selection?

Hi I have the following lines of code

Sub selection()

'Dim ws As Worksheet
Dim rng As Range
'
Set rng = Range("A2").CurrentRegion
'rng.Delete
rng.Select


End Sub

It selects me all the cells that have information in that region, including the row of A1, but I don't want the first row to be selected, is there a way I can indicate to CurrentRegion that it should select all from A2 to all the cells that have information. And no I cannot specify a range because the information that is given in the cells I want to select is variable so it's not always the same length. Any thoughts?

Upvotes: 1

Views: 3095

Answers (2)

user23314694
user23314694

Reputation: 1

Sub selection()

    ' To select current region without first column

    Dim rng As Range

    Set rng = Range("A1").CurrentRegion
    rng.Offset(0, 1).Resize(rng.Rows.Count, rng.Columns.Count - 1).Select

End Sub

Upvotes: -1

Michal
Michal

Reputation: 6009

Sub selection()

    Dim rng As Range

    Set rng = Range("A1").CurrentRegion
    rng.Offset(1, 0).Resize(rng.Rows.Count - 1, rng.Columns.Count).Select

End Sub

Upvotes: 1

Related Questions