Hello,
This is my first post so please forgive me if I am doing anything wrong. Thanks in advance for your help.
I have multiple macros in two different workbooks, and a "Master" macro which is intended to switch back and forth between activating the two books, calling subs in each. It won't even get past the first few lines:
Sub Master()
Workbooks("Weekly Feedback Raw Data.xlsm").Activate
Call Create_Defects_Raw_Data_Pivot
The Master is stored in "Blank Template with Macros.xlsm" which is the active book when Master is run. When I try to run it, I get a "Sub or Function not Defined" error and the line containing Call Create_Defects_Raw_Data_Pivot is highlighted. The workbook "Weekly Feedback Raw Data.xlsm" contains the create pivot macro. Here is the code for the create pivot macro:
Sub Create_Defects_Raw_Data_Pivot()
Dim PTcache As PivotCache
Dim PT As PivotTable
Set PTcache = ActiveWorkbook.PivotCaches.Create( _
SourceType:=xlDatabase, _
SourceData:="DefectsRawData")
Call SetUpWorksheet("DefectsRawData")
Set PT = ActiveSheet.PivotTables.Add( _
PivotCache:=PTcache, _
TableDestination:=Range("A1"))
With PT.PivotFields("units")
.Orientation = xlDataField
.Function = xlSum
.Name = "Sum of Units"
End With
With PT
.PivotFields("site").Orientation = xlPageField
.PivotFields("resolve_week").Orientation = xlColumnField
.PivotFields("item").Orientation = xlRowField
.Name = "DefectsRawDataPivot"
.PivotFields("item").AutoSort xlDescending, "Sum of Units"
.TableStyle2 = "PivotStyleLight16"
End With
Call FilterDates("resolve_week")
End Sub
This sub works fine when I run it from the feedback workbook. Shouldn't I be able to call the Create_Defects_Raw_Data_Pivot sub once the "Weekly Feedback Raw Data.xlsm" book is activated? Am I wrong in assuming that a public sub should be accessible if it is in the active workbook?
Please let me know if you need more info.
Bookmarks