Setting the select all to select some

Brighton

New Member
Joined
Aug 20, 2009
Messages
9
I am working in Excel (not 2007) and am trying to get a Macro that will run and select all Cells in a Worksheet except for the first row. What I have so far is this:

Code:
    Dim LR As Long
    LR = .Cells(Rows.Count, 1).End(xlUp).Row + 1
    Sheets("M").Activate
    Range("A2:T" & LR).Select
    Selection.Delete
I do want the command to clear the entire sheet so that it can have more data imported to it.

I get a compile error that selects the ".Cells" portion of the code.

Any ideas? Should I be doing this differently?
 

Some videos you may like

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Unless your statement is in a With construct whose object is a worksheet, remove the dot qualifier before Cells.

Code:
LR = Cells(Rows.Count, 1).End(xlUp).Row + 1
 

Brighton

New Member
Joined
Aug 20, 2009
Messages
9
Thanks very much. I really need to stop making these silly mistakes all the time.
 

Watch MrExcel Video

Forum statistics

Threads
1,102,305
Messages
5,486,072
Members
407,532
Latest member
shahbazfcca

This Week's Hot Topics

Top