TenKittens
New Member
- Joined
- Oct 5, 2015
- Messages
- 16
Context: Medium skill VBA user - Old poster that lost it's previous email
Hi,
I’ve been coming across a VBA question that would simplify my codes and I can’t find the answer. Maybe you can help me out:
Let’s say that I have three ranges that I have name in Excel: ARoot BRoot and CRoot.
I would like to run the same procedure using the three ranges I defined, without making a copy paste
For example
Copying-Pasting
Is there a way to do this with a for loop?
This is how i tried:
Obviously the second code above is not working, I don't know how to appropriately define the variables
Thanks in advance
TK
Hi,
I’ve been coming across a VBA question that would simplify my codes and I can’t find the answer. Maybe you can help me out:
Let’s say that I have three ranges that I have name in Excel: ARoot BRoot and CRoot.
I would like to run the same procedure using the three ranges I defined, without making a copy paste
For example
Copying-Pasting
Code:
A=Me.[ ARoot].Value
B=Me.[ BRoot].Value
C=Me.[CRoot].Value
Is there a way to do this with a for loop?
This is how i tried:
Code:
NameStr(0)=ARoot
NameStr(1)=BRoot
NameStr(2)=CRoot
For i_x=0 To 2
RootName= NameStr(i_x)
A=Me.[RootName].Value ''Incorrect
Next i_x
Obviously the second code above is not working, I don't know how to appropriately define the variables
Thanks in advance
TK