EDN Admin
Well-known member
I have an Excel Workbook that is supposed to let the user load their customer specific item data and then creates the charts and graphs needed for their customer presentation. There are 64 possible charts/graphs that will be created. The only
reason there wouldnt be 64 is if a specific customer did not carry items in a specific segment. For example, diapers.
I first created a Sub Macro() for each variation, then I grouped multiple macros together using a Sub Macro_Group() and Call, see example below.
Public Sub Baby()<br/>
Call Macro_Baby_Total<br/>
Call Macro_BabyDiapers<br/>
Call Macro_BAbyWipes<br/>
End Sub
The problem is the Macro-BabyDiapers has the code below in it. However, when it gets to the line<br/>
<br/>
Sheets("WT Pivot Table").Select<br/>
Call B_CLEAR_WT_PERCENTAGES"<br/>
ActiveSheet.PivotTables("PivotData").PivotFields("LEVEL 1").CurrentPage = "HBA"<br/>
ActiveSheet.PivotTables("PivotData").PivotFields("LEVEL 2").CurrentPage = "BABY CARE"<br/>
ActiveSheet.PivotTables("PivotData").PivotFields("LEVEL 3").CurrentPage = "DIAPERS"<br/>
ActiveSheet.PivotTables("PivotData").PivotFields("LEVEL 4").CurrentPage = "(ALL)"<br/>
ActiveSheet.PivotTables("PivotData").PivotFields("LEVEL 5").CurrentPage = "(ALL)"<br/>
....additional code.....<br/>
End Sub
However, when it gets to the line<br/>
<br/>
ActiveSheet.PivotTables("PivotData").PivotFields("LEVEL 3").CurrentPage = "DIAPERS"<br/>
<br/>
It stops and gives me an error, because this particular data does not have diapers in it. I need to know if there is a way for it to check Level 3 to see if Diapers exists, if not then end that Macro and move the the next called macro. Is that
possible? I probably should do this at each level, because Im sure somewhere along the line it will happen, even if not often, these users are in sales and will be freaked out by an error message. So Im assuming if there is a way to do it, it
would apply no matter what level, and I can just copy-paste-edit accordingly.
Thanks, in advance, Im new to Macros/VB and learning on the fly. I plan on enrolling in a class (preferably online) in the fall - open to suggestions; but in the iterim, Im muddling through as best I can. <hr class="sig Lisa
View the full article
reason there wouldnt be 64 is if a specific customer did not carry items in a specific segment. For example, diapers.
I first created a Sub Macro() for each variation, then I grouped multiple macros together using a Sub Macro_Group() and Call, see example below.
Public Sub Baby()<br/>
Call Macro_Baby_Total<br/>
Call Macro_BabyDiapers<br/>
Call Macro_BAbyWipes<br/>
End Sub
The problem is the Macro-BabyDiapers has the code below in it. However, when it gets to the line<br/>
<br/>
Sheets("WT Pivot Table").Select<br/>
Call B_CLEAR_WT_PERCENTAGES"<br/>
ActiveSheet.PivotTables("PivotData").PivotFields("LEVEL 1").CurrentPage = "HBA"<br/>
ActiveSheet.PivotTables("PivotData").PivotFields("LEVEL 2").CurrentPage = "BABY CARE"<br/>
ActiveSheet.PivotTables("PivotData").PivotFields("LEVEL 3").CurrentPage = "DIAPERS"<br/>
ActiveSheet.PivotTables("PivotData").PivotFields("LEVEL 4").CurrentPage = "(ALL)"<br/>
ActiveSheet.PivotTables("PivotData").PivotFields("LEVEL 5").CurrentPage = "(ALL)"<br/>
....additional code.....<br/>
End Sub
However, when it gets to the line<br/>
<br/>
ActiveSheet.PivotTables("PivotData").PivotFields("LEVEL 3").CurrentPage = "DIAPERS"<br/>
<br/>
It stops and gives me an error, because this particular data does not have diapers in it. I need to know if there is a way for it to check Level 3 to see if Diapers exists, if not then end that Macro and move the the next called macro. Is that
possible? I probably should do this at each level, because Im sure somewhere along the line it will happen, even if not often, these users are in sales and will be freaked out by an error message. So Im assuming if there is a way to do it, it
would apply no matter what level, and I can just copy-paste-edit accordingly.
Thanks, in advance, Im new to Macros/VB and learning on the fly. I plan on enrolling in a class (preferably online) in the fall - open to suggestions; but in the iterim, Im muddling through as best I can. <hr class="sig Lisa
View the full article