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 did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Dermot

Board Regular
Joined
Aug 11, 2006
Messages
139
Office Version
  1. 365
Platform
  1. Windows
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
 

MakeItSo

New Member
Joined
Jul 31, 2015
Messages
5
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 :)
 

Dermot

Board Regular
Joined
Aug 11, 2006
Messages
139
Office Version
  1. 365
Platform
  1. Windows
you need to first figure out how you know a section is missing, eg D5 is blank or something
 

MakeItSo

New Member
Joined
Jul 31, 2015
Messages
5
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
 

Dermot

Board Regular
Joined
Aug 11, 2006
Messages
139
Office Version
  1. 365
Platform
  1. Windows
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
 

Forum statistics

Threads
1,141,715
Messages
5,708,030
Members
421,540
Latest member
quocbinh

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
Top