View Full Version : Solved: Macro Equation
wonderBOi
03-07-2013, 06:12 PM
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
Sub test232()
Dim FName4
Dim FName
FSource = "Y:\MNLGSCSALNNP\Administrative\CnC\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.
wonderBOi
03-07-2013, 09:04 PM
Hi Dave,
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:
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
mancubus
03-08-2013, 08:04 AM
welcome to the forum.
do you want to open all files in a folder?
this might help:
http://www.vbaexpress.com/kb/getarticle.php?kb_id=9
enrand22
03-09-2013, 11:55 AM
hi
to loop you must use "x = x + 1" instead of "x = 1 + 1" . Now you can reach 5.
sassora
03-09-2013, 12:34 PM
This is an example of how you might 'reword' what you've written:
Sub OpenFiles()
Dim FSource As String
Dim Fname(1 To 3) As String
Dim count As Integer
FSource = "C:/Tools/"
Fname(1) = FileA
Fname(2) = FileB
Fname(3) = FileC
For count = 1 To 3
Workbooks.Open (FSource & Fname(count))
Next count
End Sub
If you want to open all excel files in a folder then Mancubus's solution is probably the way to go.
wonderBOi
03-12-2013, 03:44 AM
Hi Sassora,
your code is exactly what i'm looking for. Man, you are great. For everyone who replied, thank you as well.
I didn't know that "()" made this possible. Thank you once again
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.