-3

I have some VBA code which highlights the cells in A if they contain a value.

Is there a way to adapt this to start in cell A2 as A1 is a header.

    Option Explicit

Sub LRow()

    Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet1")  '<=== Edit Sheet Name
    Dim LRow As Long

    LRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row

    ws.Range("A1:A" & LRow).Select

End Sub
0m3r
  • 12,286
  • 15
  • 35
  • 71
Tony Chivers
  • 191
  • 11
  • Just in case you plan to use `.Select` please read [How to avoid using Select in Excel VBA](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) for a more reliable and much faster method. – Pᴇʜ Nov 15 '18 at 09:29

1 Answers1

2

You only need to change the starting cell to A2: ws.Range("A2:A" & LRow).Select

In your code it looks like this:

Sub LRow()

    Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet1")  '<=== Edit Sheet Name
    Dim LRow As Long

    LRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row

    ws.Range("A2:A" & LRow).Select

End Sub
rohrl77
  • 3,277
  • 11
  • 47
  • 73