DINESHKUMAR PALANISAMY
DINESHKUMAR PALANISAMY

Reputation: 159

Selection of range in both column and row direction in Excel VBA

I want to select the data from E1 to untill the cell that contains data in Column H. is it possible through VBA?.

I have tried with this code:

Range(Range("e1").End(xlDown), Range("h1").End(xlDown)).Select

But it selects E2 to H2.

Upvotes: 0

Views: 472

Answers (2)

ArindamD
ArindamD

Reputation: 241

Use:

Range("E1:H" & Range("H" & Rows.Count).End(xlUp).Row)

This will select the range from E1 to last populated cell of column H

Upvotes: 1

A.S.H
A.S.H

Reputation: 29352

I want to select the data from E1 to untill the cell that contains data in Column H

Will this work for you?

Range("e1", Columns("h").Find("*")).Select

Corresponds exactly to what you said if H1 is always empty.

Unless you meant the last cell that contains data in Column H? In that case:

    Range("e1", Range("h999999").End(xlUp)).Select

Upvotes: 0

Related Questions