I am getting the run-time error 76 on the line
Set f = fs.GetFolder(FolderName)
the ActiveWorkBook is called 2022M12.xlsm
the folder ""D:\SMA\Sunny Explorer\Data\Daily\" & ActiveWorkBookYear (=2022) contains a lot of CSV files to be imported one at a time
and then manipulated to a standard format before being graphed.
I am now trying to catch up on files from December 2022
The original script was running correctly
Set f = fs.GetFolder(FolderName)
the ActiveWorkBook is called 2022M12.xlsm
the folder ""D:\SMA\Sunny Explorer\Data\Daily\" & ActiveWorkBookYear (=2022) contains a lot of CSV files to be imported one at a time
and then manipulated to a standard format before being graphed.
I am now trying to catch up on files from December 2022
The original script was running correctly
VBA Code:
Sub GetCSVFiles()
'
ActiveWorkBookPath = ActiveWorkbook.Path
ActiveWorkBookName = ActiveWorkbook.Name
ActiveWorkBookYear = Left(ActiveWorkBookName, 4)
ActiveWorkBookMonth = Mid(ActiveWorkBookName, 6, 2)
ActiveWorkBookMonthList = "JanFebMarAprMayJunJulAugSepOctNovDec"
ActiveWorkBookMonthTxt = Mid(ActiveWorkBookMonthList, ((Val(ActiveWorkBookMonth) - 1) * 3) + 1, 3)
SheetCount = ActiveWorkbook.Sheets.Count
FolderName = "D:\SMA\Sunny Explorer\Data\Daily\" & ActiveWorkBookYear
FileType = ".csv"
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(FolderName)
Set fc = f.Files
For Each f1 In fc
If Right(f1, Len(FileType)) = FileType Then
If Mid(f1, 73, 4) = ActiveWorkBookYear And Mid(f1, 77, 2) = ActiveWorkBookMonth Then
Workbooks.Open (f1)
FormatCSV2XLS (SheetCount)
SheetCount = SheetCount + 1
End If
End If
Next
FormatMaxAvg (SheetCount)
CreateChart
Application.ScreenUpdating = True
'
End Sub
Last edited by a moderator: