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?
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
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
 
Upvote 0

Forum statistics

Threads
1,215,584
Messages
6,125,678
Members
449,248
Latest member
wayneho98

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top