Morning all,
Im still learning my way through VBA and hoping for some help and guidance on this problem please.
I have a module (see blow) which selects the file to be used. Another module is used to save another file and I need to use the date which is in the filename to name the being saved.
How do I pass the name of the file selected in the below code into the other module?
Any help is greatly appreciated. Thanks in advance.
Stuart
More code......
Im still learning my way through VBA and hoping for some help and guidance on this problem please.
I have a module (see blow) which selects the file to be used. Another module is used to save another file and I need to use the date which is in the filename to name the being saved.
How do I pass the name of the file selected in the below code into the other module?
Any help is greatly appreciated. Thanks in advance.
Stuart
Code:
Sub CopySourceExtract()
Dim wb1 As Workbook, wb2 As Workbook
Dim Ret1, Ret2
Dim LastRow As Long
Dim Filename As Variant
Sheets("Extract").Cells.AutoFilter
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.DisplayStatusBar = False
ActiveSheet.DisplayPageBreaks = False
Application.CutCopyMode = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Set wb1 = ActiveWorkbook
ChDir "\\Code that links the folders to file etc etc\"
Ret2 = Application.GetOpenFilename("Excel Files (*.csv*), *.csv*", _
, "Please select file")
If Ret2 = False Then End
Dim strPath As String
strPath = Ret2
Dim strFile As String
strFile = Right(strPath, Len(strPath) - InStrRev(strPath, "\"))
Filename = CreateObject("Scripting.FileSystemObject").GetBaseName(strFile)
Set wb2 = Workbooks.Open(Ret2, Local:=True, ReadOnly:=True)
ThisWorkbook.Activate