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?
 

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.
 

Forum statistics

Threads
1,081,545
Messages
5,359,445
Members
400,528
Latest member
Ratish52

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top