VBA to Select Range to first Column without Header
Posted on 2012-03-17
I am using the following code to select a range of cells in a worksheet:
' Selects the entire populated range of the active worksheet
' Keyboard Shortcut: Ctrl+Shift+R
LastRow = Range("A" & Rows.Count).End(xlUp).Row
LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
Range(ActiveCell, Cells(LastRow, LastCol)).Select
This code also selects cells outside the continous block of data. How do I get it to stop selecting columns at the first column that does not have a header?
Thanks for your help.