Want to Change Range Selected in Formula

D

DogLover

I would like to pass a variable through a function. Based on the value, I
have some ranges already name ie. Dataquestion#. I would like to be able to
change the named range to use in this formula based on numbers, such as mQNo.

Any help would be appreciated.

mQNo = 1
Set mQuestionRange1 = Worksheets("Data").Range(Chr(34) & "DataQuestion" &
mQNo & Chr(34))
 
J

joel

This is siomple. I don't think you understadn strings. You don't nee
a second set of double quotes. It is that simple

for example

Var1 = "abc"
Var2 = "def"

Var12 & Var2 will equal "abcdef"

You don't need to do this
chr(34) & Var1 & Var2 & chr(34)
It would results in this
""abcdef""

Likewise this is wrong
Set mQuestionRange1 = Worksheets("Data").Range(Chr(34) & "DataQuestion
& mQNo & Chr(34))

Instead use this
Set mQuestionRange1 = Worksheets("Data").Range("DataQuestion" & mQNo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top