Forum Discussion

scrail2004's avatar
scrail2004
Brass Contributor
Aug 21, 2025
Solved

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

  • scrail2004's avatar
    scrail2004
    Brass Contributor

    m_tarler, Range(Selection, Cells(1,Selection.Column()).Select turns red when I paste it into the macro.

    • HansVogelaar's avatar
      HansVogelaar
      MVP

      Change it to

      Range(Selection, Cells(1, Selection.Column)).Select

  • m_tarler's avatar
    m_tarler
    Bronze Contributor

    there are various ways.  maybe something like:

     Range(Selection, Cells(1,Selection.Column()).Select

Resources