Defining Range with Variables

EL_SB

New Member
Joined
Mar 19, 2016
Messages
17
I have a changing range always composed of 1 column. I have the start and end points determined in a loop as L and J.

How do I refer to that Range if the column is always "I"?

I tried SummarySheet.Range(Cells(9, L), Cells(22, J)) but no luck.

I would like to feed this Range into the COUNTIF function to search for a specific string.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi,

If you are using Cells(row,col) ... just use the column number ... ie. for Col I : 9 .. and for Col L : 12 ...

HTH
 
Upvote 0
If you are using Cells(row,col) ... just use the column number ... ie. for Col I : 9 .. and for Col L : 12 ...
You can also use the letters, but those letters must be quoted (otherwise VB thinks they are variable names).
 
Upvote 0
How do I refer to that Range if the column is always "I"?

I tried SummarySheet.Range(Cells(9, L), Cells(22, J)) but no luck.
Try it this way...

SummarySheet.Range(Cells(9, "I"), Cells(22, "I"))

Of course, doing it that way does not use L and J. If L and J are variables containing the start and end rows for the range, then what you want is this...

SummarySheet.Range(Cells(L, "I"), Cells(J, "I"))
 
Upvote 0

Forum statistics

Threads
1,216,113
Messages
6,128,904
Members
449,477
Latest member
panjongshing

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