Refer dynamically to the column argument in a range statement

Glory

Well-known Member
Joined
Mar 16, 2011
Messages
640
I need a way to refer dynamically to the column argument in a range statement.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
This isn’t working:
<o:p> </o:p>
Code:
e = 1
<o:p> </o:p>
Range(Cells(1, e).Columns & “2”).
<o:p> </o:p>
The desired result is “Range(“A2”)”, except the column will change to become “B” and “C” as the code loops.
<o:p> </o:p>
Any ideas?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
In other words, I’m trying to convert a column number to a column letter.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
Any help will be appreciated.
 
Upvote 0
In other words, I’m trying to convert a column number to a column letter.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
Any help will be appreciated.
Try
Code:
MsgBox Split(Columns(2).Address(, 0), ":")(0)
 
Upvote 0
Use
Code:
Cells(2,e)
I need a way to refer dynamically to the column argument in a range statement.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
This isn’t working:
<o:p> </o:p>
Code:
e = 1
<o:p> </o:p>
Range(Cells(1, e).Columns & “2”).
<o:p> </o:p>
The desired result is “Range(“A2”)”, except the column will change to become “B” and “C” as the code loops.
<o:p> </o:p>
Any ideas?
 
Upvote 0
I was looking for a way to refer to the column name in the range method because I need to “Copy” a series of ranges.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
eg “Range(DynamicColumn & DynamicRow “:”DynamicColumn & DynamicRow”)
<o:p> </o:p>
Is there a way to use the Cells property to refer to a range of cells?
 
Upvote 0
Code:
Range(Cells(),Cells())

You can also find this from Excel VBA help -- well, at least you could. I don't know if the newer versions of help provide that information.

I was looking for a way to refer to the column name in the range method because I need to “Copy” a series of ranges.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
eg “Range(DynamicColumn & DynamicRow “:”DynamicColumn & DynamicRow”)
<o:p> </o:p>
Is there a way to use the Cells property to refer to a range of cells?
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,223
Members
452,896
Latest member
IGT

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