Excel Macro Quick Question

MakeItSo

New Member
Joined
Jul 31, 2015
Messages
5
Hello Everyone,

I was wondering if anyone could help me out with the "programing" of a section of my macro.

I created a macro by recording a set of actions but hadn't realized that the sections I was changing were dynamic, meaning that some weeks the information is there, some weeks it's not.
What the macro does is basically take the raw data file and turn it into a pivot table.

When I run my macro the following error comes up in yellow on the Debugger:

ActiveSheet.PivotTables("PivotTable3").PivotFields("Sub Category Name"). _
PivotItems("Request my data").ShowDetail = False

Is there any way that I could program the macro to skip this section "Request my data" or any other sections if they're not present in the raw data and still complete the pivot table with the information that is present?

Thanks in advance for your help!
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
You need to use an IF test in your code, to check if a certain section is there or not, ie
VBA Code:
If **** Then
  'the info is there, extract it
End If
so you need to figure out how the code can decide if the data is there or not
 
Upvote 0
Thank you Dermot for your help!

Would you be able to create the IF statement for using the example piece of code I posted above so I can visualize it better?

Trying to figure out how I would implement that in the code.

Thank you in advance for your help with this :)
 
Upvote 0
you need to first figure out how you know a section is missing, eg D5 is blank or something
 
Upvote 0
I see.

Unfortunately there wouldn't be a cell that's empty, it would just be that this specific category will not be in the report.

Don't know if that is possible
 
Upvote 0
Well, how is VBA supposed to know if it's there or not?
Until you figure that out, it's impossible to do what you want
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top