简体   繁体   中英

VBA -Excel Find First cell With Data

I am currently using the following piece of code in a macro to find the first cell will data in a row, and to move the cursor to that cell.

    Do While IsEmpty(ActiveCell)
    ActiveCell.Offset(1, 0).Select
    Loop

It would like to find a way to be more efficient, this code scrolls down and takes a little to much time.

Any Suggestions would be appreciated.

Thanks!

I would use xlDown for it. Would work in the other direction (xlUp) and for columns (xlLeft, xlRight), too:

Sub JumpToNextNotEmptyCellBelow()

    ActiveCell.End(xlDown).Select  
 
End Sub

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