Can I use a variable to select an entire row?

shiver24

New Member
Joined
Jul 11, 2002
Messages
3
Hello-


I have a large macro that copies formulas all the way down to the bottom of the worksheet. Well, I need to clean up the rows below my actual data. So I've come up with the following:

Dim EndRow As Range
Set EndRow = Range("I3").Value
Rows("EndRow:EndRow").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp

The Cell I3 is populated with the Row Number that I want to start deleting at. I've tested the Variable EndRow and it does return the correct value. This snippent is part of a much larger macro, but the debugger takes me right to the Set Line above.

Is this possible? Can I pass a value from a variable to the row number?

Please let me know, if I can get this to work it will save me many hours of work.

Thanks!!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

onlyadrafter

Well-known Member
Joined
Aug 19, 2003
Messages
5,703
Platform
  1. Windows
Hello,

To get this to work I have changed the code to the following:

Code:
EndRow = Range("I3").Value
Rows(EndRow).Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp

Is this suitable?
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,096
Messages
5,768,061
Members
425,451
Latest member
JohnBrooksBiddle

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
Top