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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
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?
 
Upvote 0

Forum statistics

Threads
1,215,055
Messages
6,122,902
Members
449,097
Latest member
dbomb1414

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