Using cell value as a variable for column value

ChristineJ

Well-known Member
Joined
May 18, 2009
Messages
576
Office Version
  1. 365
Platform
  1. Windows
This excerpt of code works to define two ranges of columns.
Rich (BB code):
Call SplitAny(Range("D:R,FZ:GK"), Range("68:205,542:795"), Range("D68"), Range("FZ566"))

This excerpt of code works to replace the "D" with the value in cell ED33.

Rich (BB code):
Call SplitAny(Range(Range("ED33").Value & ":Z,FZ:GK"), Range("68:205"), Range("D68"), Range("FZ566"))

I also now want to replace the "R", "FZ", and "GK" in the first line of code with the cell values in ED34, ED35, and ED36, respectively.

I am trying the following, but getting syntax errors.

Rich (BB code):
Call SplitAny(Range(Range("ED33").Value:Range("ED34").Value,Range("ED35").Value:Range("ED36").Value), Range("68:205"), Range("D68"), Range("FZ566"))

How do I need to tweak this? Thanks.
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

p45cal

Well-known Member
Joined
Nov 10, 2009
Messages
4,763
try:
Code:
Call SplitAny(Range(Range("ED33").Value & ":" & Range("ED34").Value & "," & Range("ED35").Value & ":" & Range("ED36").Value & ""), Range("68:205"), Range("D68"), Range("FZ566"))
(Bear in mind that your second code snippet:
Code:
Call SplitAny(Range([COLOR=#ff0000]Range("ED33").Value [/COLOR]& ":Z,FZ:GK"), Range("68:205"), Range("D68"), Range("FZ566"))
is not equivalent to your first:
Code:
Call SplitAny(Range("[COLOR=#ff0000]D:R,FZ:GK[/COLOR]"), Range("68:205[B][COLOR=#0000ff],542:795[/COLOR][/B]"), Range("D68"), Range("FZ566"))
since it misses out the blue highlighted bit.)
 

ChristineJ

Well-known Member
Joined
May 18, 2009
Messages
576
Office Version
  1. 365
Platform
  1. Windows
Wonderful! It works perfectly.

I was playing with the row ranges as well and did not post identical versions of that part. But that is all OK now.

Appreciate the quick response. This really helps!
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,218
Office Version
  1. 365
Platform
  1. Windows
Christine

Out of curiousity, what does the SplitAny function/sub do?
 

ChristineJ

Well-known Member
Joined
May 18, 2009
Messages
576
Office Version
  1. 365
Platform
  1. Windows
It is part of code that splits the screen into two screens that both have scrollbars and hides all of the cells where I have content. The SplitAny sub then unhides the cells that are to appear in the left and the right screen and properly positions them.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,499
Messages
5,596,515
Members
414,074
Latest member
Matthew Kakde

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
Top