Using variables to select rows

PapaSmurf

Board Regular
Joined
Nov 4, 2005
Messages
105
Hi,

I am trying to select a range of Rows using
Rows(variable1:variable2).Select

instead of specifying the row numbers like in
Rows("10:12").Select

this doesn't work can someone tell me how to write it so it will?

THANKS
:rolleyes:
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Try this
Code:
Rows(variable1&":"&variable2).Select
By the way why are you selecting the rows?
 
Upvote 0
"Rows(variable1&":"&variable2).Select " doesn't work

yes I want to move the rows elsewhere, I'm going to cut and paste them.
 
Upvote 0
Works for me.
Code:
Rows(variable1 & ":" & variable2).Select

Where are you moving the rows?
Code:
Rows(variable1 & ":" & variable2).Cut

Range("A1").PasteSpecial
Code:
Rows(variable1 & ":" & variable2).Copy Range("A1").PasteSpecial
 
Upvote 0
aah it works now,
I forgot the spaces.
Thanks

I need to sort the rows by numbers in column B, in ascending order, but
with numbers 16400 and 28166 first.
Is there way to do this?
 
Upvote 0

Forum statistics

Threads
1,203,241
Messages
6,054,322
Members
444,717
Latest member
melindanegron

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