I'm trying to sort through several workbooks that all have a main worksheet starting with the year '2020'
I'd like to simply loop through each workbook and change the name but the following code won't work:
Sheets("2020-*").Name = "MAIN"
However, the following code does work:
Sheets("2020-07-01 11.05.04").Name = "MAIN"
Here's the full code:
Sub dTa_dTb_fix()
'
' dTa_dTb_fix Macro
Dim FolderPath As String, path As String, count As Integer
FolderPath = "C:\Data_Analysis\7-Pass_EVAP"
path = FolderPath & "\2020-*.xlsx"
Filename = Dir(path)
Workbooks.Open (FolderPath & "\Combined_7.xlsx")
count = 2
Application.ScreenUpdating = False
Do While Filename <> ""
Set ClosedBook = Workbooks.Open(Filename)
Sheets("2020-*").Name = "MAIN"
Worksheets("MAIN").ListObjects("Table1").ListColumns("dTa").DataBodyRange.FormulaR1C1 = "=ABS(AVERAGE([@[EVAPORATOR PAO OUTLET TEMP °C]]-[@[EVAPORATOR PAO INLET TEMP °C]])-[@[CONDENSER PAO INLET TEMP °C ]])"
Worksheets("MAIN").ListObjects("Table1").ListColumns("dTb").DataBodyRange.FormulaR1C1 = "=ABS(AVERAGE([@[EVAPORATOR PAO INLET TEMP °C]]-[@[EVAPORATOR PAO OUTLET TEMP °C]])-[@[CONDENSER PAO OUTLET TEMP °C ]])"
ClosedBook.Close SaveChanges:=False
Filename = Dir()
count = count + 1
Loop
Application.ScreenUpdating = True
End Sub
Can someone help please?