简体   繁体   中英

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM