Hi all, So I currently have the current code. Currently the macro saves the files in this folder but I will need to save different files to more than one folder and want to see if I can set the macro up to create these folders e.g. for it to create a Test folder and save the files 1111 and 2222 in it rather than me having already created the folder Test where the files save...
These files are also saving updates for a number of different stores, I also am required to create a macro that will automatically add in new stores when necessary eg 3333 and area codes eg. testtwo etc.
These files are also saving updates for a number of different stores, I also am required to create a macro that will automatically add in new stores when necessary eg 3333 and area codes eg. testtwo etc.
Rich (BB code):
'==========>>
Option Explicit
'---------->>
Sub PassVariables()
Call Tester(myYear:=2014, _
myQuarter:="Q4", _
myFolder:="TST", _
mySaveAsFolder:="Test", _
mySaveAsName:="1111", _
mySaveAsName2:="2222")
End Sub
'---------->>
Public Sub Main(myYear As Variant, myQuarter As String, _
myFolder As String, _
mySaveAsFolder As String, _
mySaveAsName As String, _
mySaveAsName2 As String)
Dim WB As Workbook
Dim WS As Worksheet
Dim spath As String
Dim sSaveAsPath As String
Dim sFilename As String
Dim sFullname As String
Dim aStr As String
aStr = myQuarter & " " & myYear
spath = "X:\specific folder\" & myYear & "\" & aStr & "\TMT\" & myFolder
sSaveAsPath = "X:\specific folder\" & myYear & "\" & aStr & "\TMT\" & mySaveAsFolder
sFilename = "ST " & aStr & ".xlsm"
sFullname = spath & "\" & sFilename
ChDir spath
Workbooks.Open Filename:=sFullname, Updatelinks:=0
ActiveCell.Offset(-1, 0).FormulaR1C1 = mySaveAsName
Set WS = ActiveSheet
Set WB = Workbooks.Add(xlWBATWorksheet)
WS.Range("A1:S84").Copy
WB.Sheets(1).Range("A1").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
ChDir sSaveAsPath
ActiveWorkbook.SaveAs Filename:=sSaveAsPath & "\" & mySaveAsName, _
FileFormat:=xlOpenXMLWorkbook, _
CreateBackup:=False
ChDir spath
Workbooks.Open Filename:=sFullname, Updatelinks:=0
ActiveCell.Offset(-1, 0).FormulaR1C1 = mySaveAsName2
Set WS = ActiveSheet
Set WB = Workbooks.Add(xlWBATWorksheet)
WS.Range("A1:S84").Copy
WB.Sheets(1).Range("A1").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
ChDir sSaveAsPath
ActiveWorkbook.SaveAs Filename:=sSaveAsPath & "\" & mySaveAsName2, _
FileFormat:=xlOpenXMLWorkbook, _
CreateBackup:=False
End Sub
'<<==========