Selecting a variable bounded range

rdwinslow

New Member
Joined
Aug 5, 2010
Messages
6
Hi. I'm going bald on this one! I need to select a range bounded by the values in cells.

I have a choice:

I can select based on values CopyRow1, CopyCo1l to CopyRow2, CopyCol2 where I can calculate the second set as an offset of the first, which is variable - these being integers. ie CopyRow1 = 3, CopyCol1 = 2, CopyRow2 = 20, CopyCol2 = 10 (Just possible values)

or

I can select based on values contained in the variables CopyBox1 and CopyBox2 which are strings - ie CopyBox1 = B3, CopyBox2 = J20

I can easily get these correct values, but every permutation of Range and cells I have tried (including making another variable named CopyRange which is Dim'd as Range and trying Range(CopyRange).Select where CopyRange is "B3:J20" - or any other range depending of the calculates start and end

I have little hair left, and I can't afford to lose much more.

Somebody please help me!

Thanks
Rob :confused:
 
Last edited:

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Not entirely sure what you tried but either:
Code:
Range(Cells(Copyrow1, copycol1), cells(copyrow2, copycol2))
or
Code:
Range(copybox1, copybox2)
should work (qualified by sheet as required)
 
Upvote 0
Not entirely sure what you tried but either:
Code:
Range(Cells(Copyrow1, copycol1), cells(copyrow2, copycol2))


or

Code:
Range(copybox1, copybox2)
should work (qualified by sheet as required)

both elicit a

Run-time error '1004': Select method of Range class failed

Any ideas? Should I NOT be using a .Select after them? I need to copy the values of the cells into another worksheet.

Thanks for the help!
Rob
 
Upvote 0
There is almost never a need to select ranges in code, but I can't really assist you with code unless I can actually see what you are using. (I suspect your error is that you haven't specified the sheet)
 
Upvote 0
I found my solution - rather than selecting the range then copying, I just set it to

Range(CopyBox1, CopyBox2).Copy

.Select was not the answer....

Sigh... I lost a lot of good hair over that! :LOL:

Thanks for helping me work through it!
Rob
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,939
Members
449,094
Latest member
teemeren

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