Using Variable in Range selection

losamfr17

Board Regular
Joined
Jun 10, 2016
Messages
149
Hi,

I want to grab rngCopy in my loop of sheets.
Problem: the code below selects all cells between columns C & H.
Desired result: I want to ONLY select cells between C thru D AND cells in H but not the cells in between (just like this code would if rngCopy=9 -- Sheets(i).Range("C7:D9, H7:H9").select).

Any idea how to make that happen?

Code:
Dim rngCopy As Range

Set rngCopy = Sheets(i).Range("C7:D" & rowsCopy, "H7:H" & rowsCopy)


Sheets(i).Range("C7:D" & rowsCopy, "H7:H" & rowsCopy).Select
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
You were close. :cool:

Code:
Sheets(i).Range("C7:D" & [B]rowsCopy & ",[/B]H7:H" & rowsCopy).Select
 
Upvote 0

Forum statistics

Threads
1,214,954
Messages
6,122,461
Members
449,085
Latest member
ExcelError

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