Hope someone can help me.
My base macro works fine when I run it on one worksheet (with any name), but when I run the macro below, which based on my research should run across all the workbooks, it only runs on the worksheet I'm on. My workbook will have a different number of worksheets, with different names everytime (it's a data extract I need to format).
Sub ExportMaster()
Dim xsheet As Worksheet
For Each xsheet In ThisWorkbook.Worksheets
Call Export
Next xsheet
End Sub
Am I missing something?
I'm wondering if it has something to do with this section of the Macro as it has 'activesheet' commands:
Selection.AutoFilter
Columns("A:A").Select
Selection.NumberFormat = "m/d/yyyy"
ActiveWorkbook.ActiveSheet.AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.ActiveSheet.AutoFilter.Sort.SortFields.Add2 _
Key:=Range("A8"), SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.ActiveSheet.AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
Thanks in advance
My base macro works fine when I run it on one worksheet (with any name), but when I run the macro below, which based on my research should run across all the workbooks, it only runs on the worksheet I'm on. My workbook will have a different number of worksheets, with different names everytime (it's a data extract I need to format).
Sub ExportMaster()
Dim xsheet As Worksheet
For Each xsheet In ThisWorkbook.Worksheets
Call Export
Next xsheet
End Sub
Am I missing something?
I'm wondering if it has something to do with this section of the Macro as it has 'activesheet' commands:
Selection.AutoFilter
Columns("A:A").Select
Selection.NumberFormat = "m/d/yyyy"
ActiveWorkbook.ActiveSheet.AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.ActiveSheet.AutoFilter.Sort.SortFields.Add2 _
Key:=Range("A8"), SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.ActiveSheet.AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
Thanks in advance