Forum Discussion
Excel (on Mac) Macro Highlight to the Top of a Column
Column F in the below table includes a blank cell. In a macro, I want to highlight cells F2 to F10.
Since I could have any number of rows of data, I wrote the macro to get me to the last row of data, then highlight my way up using:
Range(Selection, Selection.End(xlUp)).Select
But since I could have any number of blanks in Column F, I had to repeat that line 12 times to be sure my highlighted range would always go to the top of the column.
Is there a way to anchor the highlighting at the last row of data (as I have done), but then make E2 the "top" of my highlighted range?
Change it to
Range(Selection, Cells(1, Selection.Column)).Select
4 Replies
- scrail2004Brass Contributor
HansVogelaar - that worked. Thx!
- scrail2004Brass Contributor
m_tarler, Range(Selection, Cells(1,Selection.Column()).Select turns red when I paste it into the macro.
Change it to
Range(Selection, Cells(1, Selection.Column)).Select
- m_tarlerBronze Contributor
there are various ways. maybe something like:
Range(Selection, Cells(1,Selection.Column()).Select