So I need to set a workbook name as a variable as it changes every time an updated version is downloaded.
So far here is the macro I have set. The problem occurs because the workbook name, which today is "MasterMDs-2020-01-27" will change constantly for the current date. Initially thought of just renaming the sheet every time in the code, but then realized a variable could solve the issue. Just uncertain of the syntax as I am not a VBA expert.
Any help is appreciated
So far here is the macro I have set. The problem occurs because the workbook name, which today is "MasterMDs-2020-01-27" will change constantly for the current date. Initially thought of just renaming the sheet every time in the code, but then realized a variable could solve the issue. Just uncertain of the syntax as I am not a VBA expert.
VBA Code:
Cells.Select
Selection.Columns.AutoFit
Columns("A:G").Select
Selection.Delete Shift:=xlToLeft
Columns("B:C").Select
Selection.Delete Shift:=xlToLeft
Columns("D:V").Select
Selection.Delete Shift:=xlToLeft
Columns("F:F").Select
Selection.Delete Shift:=xlToLeft
Columns("G:AD").Select
Selection.Delete Shift:=xlToLeft
ActiveWindow.ScrollColumn = 1
Columns("A:F").Select
Selection.AutoFilter
ActiveWorkbook.Worksheets("MasterMDs-2020-01-27").AutoFilter.Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets("MasterMDS-2020-01-27").AutoFilter.Sort.SortFields. _
Add2 Key:=Range("A1:A5971"), SortOn:=xlSortOnValues, Order:=xlDescending _
, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("MasterMDs-2020-01-27").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveSheet.Range("$A$1:$F$5971").AutoFilter Field:=2, Criteria1:="TRUE"
ActiveSheet.Range("$A$1:$F$5971").AutoFilter Field:=3, Criteria1:="TRUE"
Any help is appreciated