Ashleyuk1984
Senior Member
I have a really long excel macro... I will shorten it here to a few lines and give you an example to what I actually want.
You see, "Folder" is firstly being declared at the start, but then it is needed at the bottom... Of course I could switch it to the bottom, but it's not the order I want to do things.
How can I get Part2 to get the "Folder" string?
Thanks
---EDIT---
Typical, I've only gone and solved it again.
In case anyone wants to know, I just declared the variable like this.
Doing this, I was able to use it in Part2.
Code:
Sub Part1()
Dim Folder As String
Folder = InputBox("Reference")
If Len(Dir("C:\Ashley\" & Folder, vbDirectory)) = 0 Then
MkDir ("C:\Ashley\" & Folder)
End If
///// Lots of code /////
Call Part2
End Sub
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Sub Part2()
///// Lots of code /////
ActiveWorkbook.SaveAs Filename:= _
"C:\Ashley\" & Folder & "file.xls", FileFormat _
:=xlTextPrinter, CreateBackup:=False
End Sub
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
You see, "Folder" is firstly being declared at the start, but then it is needed at the bottom... Of course I could switch it to the bottom, but it's not the order I want to do things.
How can I get Part2 to get the "Folder" string?
Thanks
---EDIT---
Typical, I've only gone and solved it again.
In case anyone wants to know, I just declared the variable like this.
Code:
Call Part2(Folder)
End Sub
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Sub Part2(Folder As String)
Doing this, I was able to use it in Part2.
Last edited: