Dear all,
I have a problem with the PivatTable properties in Excel and VBA. The problem is as follows:
This is a example table:
<table x:str="" style="border-collapse: collapse; width: 290pt;" width="387" border="0" cellpadding="0" cellspacing="0"><col style="width: 98pt;" width="131"> <col style="width: 48pt;" span="4" width="64"> <tbody><tr style="height: 12.75pt;" height="17"> <td class="xl24" style="height: 12.75pt; width: 98pt;" width="131" height="17">Sum of store_sales</td> <td class="xl24" style="border-left: medium none; width: 48pt;" width="64"> </td> <td class="xl24" style="border-left: medium none; width: 48pt;" width="64">time_id</td> <td class="xl24" style="border-left: medium none; width: 48pt;" width="64"> </td> <td class="xl24" style="border-left: medium none; width: 48pt;" width="64"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl24" style="border-top: medium none; height: 12.75pt;" height="17">product_id</td> <td class="xl24" style="border-top: medium none; border-left: medium none;">store_id</td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">367</td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">368</td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">369</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl24" style="border-top: medium none; height: 12.75pt;" x:num="" align="right" height="17">1</td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">3</td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl24" style="border-top: medium none; height: 12.75pt;" height="17"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">6</td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl24" style="border-top: medium none; height: 12.75pt;" height="17"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">7</td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="11.4" align="right">11,4</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl24" style="border-top: medium none; height: 12.75pt;" height="17"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">11</td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl24" style="border-top: medium none; height: 12.75pt;" height="17"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">13</td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl24" style="border-top: medium none; height: 12.75pt;" height="17"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">14</td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;">
</td> </tr> </tbody></table>
(the format is not real clear, but I will explain)
This is a part of a PivotTable where:
Sum of Store_sales is located in the datafield(one record; 11,4)
product_id and store_id are Row-Items
Time_id is a column item.
Now, I want the properties of the cell containing 11,4. I've made it so far in VBA that I can ask what his column-items and his row-item are.
But how do I get VBA to return the valueheaders of those columns and rows? So actually, I want VBA to also return the names: product_id, store_id and time_id. This is because I need those headers to create a query which I send to a Access database.
Is someone able to give me a hint? Is there a method for this in VBA?
Thank you in advance!
I have a problem with the PivatTable properties in Excel and VBA. The problem is as follows:
This is a example table:
<table x:str="" style="border-collapse: collapse; width: 290pt;" width="387" border="0" cellpadding="0" cellspacing="0"><col style="width: 98pt;" width="131"> <col style="width: 48pt;" span="4" width="64"> <tbody><tr style="height: 12.75pt;" height="17"> <td class="xl24" style="height: 12.75pt; width: 98pt;" width="131" height="17">Sum of store_sales</td> <td class="xl24" style="border-left: medium none; width: 48pt;" width="64"> </td> <td class="xl24" style="border-left: medium none; width: 48pt;" width="64">time_id</td> <td class="xl24" style="border-left: medium none; width: 48pt;" width="64"> </td> <td class="xl24" style="border-left: medium none; width: 48pt;" width="64"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl24" style="border-top: medium none; height: 12.75pt;" height="17">product_id</td> <td class="xl24" style="border-top: medium none; border-left: medium none;">store_id</td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">367</td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">368</td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">369</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl24" style="border-top: medium none; height: 12.75pt;" x:num="" align="right" height="17">1</td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">3</td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl24" style="border-top: medium none; height: 12.75pt;" height="17"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">6</td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl24" style="border-top: medium none; height: 12.75pt;" height="17"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">7</td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="11.4" align="right">11,4</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl24" style="border-top: medium none; height: 12.75pt;" height="17"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">11</td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl24" style="border-top: medium none; height: 12.75pt;" height="17"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">13</td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl24" style="border-top: medium none; height: 12.75pt;" height="17"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;" x:num="" align="right">14</td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl24" style="border-top: medium none; border-left: medium none;">
</td> </tr> </tbody></table>
(the format is not real clear, but I will explain)
This is a part of a PivotTable where:
Sum of Store_sales is located in the datafield(one record; 11,4)
product_id and store_id are Row-Items
Time_id is a column item.
Now, I want the properties of the cell containing 11,4. I've made it so far in VBA that I can ask what his column-items and his row-item are.
Code:
Column = Application.Range(chosenCell).PivotCell.ColumnItems.Item(1)
Row = Application.Range(chosenCell).PivotCell.RowItems.Item(1)
Row2 = Application.Range(chosenCell).PivotCell.RowItems.Item(2)
Is someone able to give me a hint? Is there a method for this in VBA?
Thank you in advance!