Macro Equation

wonderBOi

New Member
Joined
Mar 7, 2013
Messages
6
I don't know if this is the correct term, but I hope you guys understand. Please bear with me as I'm a newbie when it comes to this.

I am having a hard time to reflect one equation to another equation. I am not sure but this might need dimming. Requesting for backup :p


Code:
Sub test232()
Dim FName4
Dim FName


FSource = "C:\Tools\"


FName4 = "All-In-One Updater\KCForwarder Updater*.xls*"
FName = FName & "4"


Workbooks.Open (FSource & FName)


End Sub


I want FName to reflect the FName4 value.
 

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.
Why do you want to do this? Why not just use FName4 directly?
 
Upvote 0
Hi Joe,

Thanks for your response. The code above is just an example. Im doing it because im performing a loop. there's a lot of links and i want to shorten the code.

my loop code is like this:

Code:
FSource = "C:/Tools/"
FName1 = FileA
FName2 = FileB
FName3 = FileC

x = 1
Loop1:
x = 1 + 1
If x = 5 Then GoTo EndThis


FName = FName & x

Workbooks.Open (FSource & FName)

GoTo Loop1

like that
so i need to call FName to increment the value from FName1 to FName3 for example
 
Last edited:
Upvote 0
That won't work. FName has the initial (default) value of "" (empty). So,
FName = Fname & x becomes whatever the value of x is. Say x is 1 then on the first time through the loop you get:
FName = 1, the next pass yields FName = 12 ....

You can adapt this:
Code:
Sub test()
Dim fNam
fNam = Array("File1", "File2", "File3", "File4")
For x = LBound(fNam) To UBound(fNam)
    MsgBox fNam(x)
Next x
End Sub
 
Upvote 0
How bout if like this:

FName = "FName" & x

and then ex. FName = FName4

then it will call whatever the value of FName4
 
Upvote 0

Forum statistics

Threads
1,215,537
Messages
6,125,398
Members
449,222
Latest member
taner zz

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