VBA to copy header in multi-row pivot table to blank rows

coppertop18

New Member
Joined
Apr 30, 2009
Messages
29
My pivot table is in tabular report layout and I have 2 rows; however, the first row has many blanks due to multiple choices for the 2nd row of data selected. Is there a way to change setting to have to fill all blank cells with repeating label from above? VBA? Report setting? Please help.
<table style="width: 919px; height: 162px;" border="0" cellpadding="0" cellspacing="0"><col style="width: 356pt;" width="475"> <col style="width: 333pt;" width="444"> <tbody><tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt; width: 356pt; font-size: 10pt; color: black; font-weight: 700; text-decoration: none; font-family: Arial;" width="475" height="17">About Blood Sugar</td> <td style="width: 333pt;" width="444">Answers to Your Questions on How Blood Sugar Affects Type 2 Diabetes</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt; font-size: 10pt; color: black; font-weight: 700; text-decoration: none; font-family: Arial;" height="17">
</td> <td>Find Out About Blood Sugar & Type 2 Diabetes</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt; font-size: 10pt; color: black; font-weight: 700; text-decoration: none; font-family: Arial; border-width: medium medium 0.5pt; border-style: none none solid; border-color: -moz-use-text-color -moz-use-text-color rgb(149, 179, 215);" height="17">
</td> <td>Find Out About How To Treat Type 2 Diabetes.</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt; font-size: 10pt; color: black; font-weight: 700; text-decoration: none; font-family: Arial;" height="17">About High Blood Glucose</td> <td>Find Out About High Blood Glucose and Type 2 Diabetes</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt; font-size: 10pt; color: black; font-weight: 700; text-decoration: none; font-family: Arial; border-width: medium medium 0.5pt; border-style: none none solid; border-color: -moz-use-text-color -moz-use-text-color rgb(149, 179, 215);" height="17">
</td> <td>Find Out About How To Treat Type 2 Diabetes.</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt; font-size: 10pt; color: black; font-weight: 700; text-decoration: none; font-family: Arial;" height="17">About High Blood Sugar</td> <td>Find Out About High Blood Sugar & Type 2 Diabetes</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt; font-size: 10pt; color: black; font-weight: 700; text-decoration: none; font-family: Arial; border-width: medium medium 0.5pt; border-style: none none solid; border-color: -moz-use-text-color -moz-use-text-color rgb(149, 179, 215);" height="17">
</td> <td>Find Out About How To Treat Type 2 Diabetes.</td> </tr> </tbody></table>
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I do this a lot.
1. Insert a column to the left of the pivot table.
2. put this formula "=if(B2="",A1,B2)" in the the second cell of the inserted column, next to the first cell of data.
Hide column B


Like this:

<TABLE style="WIDTH: 675pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=899><COLGROUP><COL style="WIDTH: 128pt; mso-width-source: userset; mso-width-alt: 6217" width=170><COL style="WIDTH: 132pt; mso-width-source: userset; mso-width-alt: 6436" width=176><COL style="WIDTH: 415pt; mso-width-source: userset; mso-width-alt: 20224" width=553><TBODY><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; WIDTH: 128pt; HEIGHT: 15pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" height=20 width=170>col A</TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; WIDTH: 132pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" width=176>col B</TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; WIDTH: 415pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" width=553>Col C</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl70 height=20>About Blood Sugar</TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #efefef; WIDTH: 132pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl65 width=176>About Blood Sugar


</TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: #efefef; WIDTH: 415pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=553>Answers to Your Questions on How Blood Sugar Affects Type 2 Diabetes</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl70 height=20>About Blood Sugar</TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #efefef; WIDTH: 132pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl65 width=176></TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: #efefef; WIDTH: 415pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=553>Find Out About Blood Sugar & Type 2 Diabetes</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl70 height=20>About Blood Sugar</TD><TD style="BORDER-BOTTOM: black 0.5pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #efefef; WIDTH: 132pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl67 width=176></TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: #efefef; WIDTH: 415pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=553>Find Out About How To Treat Type 2 Diabetes.</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl70 height=20>About High Blood Glucose</TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #efefef; WIDTH: 132pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl65 width=176>About High Blood Glucose</TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: #efefef; WIDTH: 415pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=553>Find Out About High Blood Glucose and Type 2 Diabetes</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl70 height=20>About High Blood Glucose</TD><TD style="BORDER-BOTTOM: black 0.5pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #efefef; WIDTH: 132pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl67 width=176></TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: #efefef; WIDTH: 415pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=553>Find Out About How To Treat Type 2 Diabetes.</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl70 height=20>About High Blood Sugar</TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #efefef; WIDTH: 132pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl65 width=176>About High Blood Sugar</TD><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: #efefef; WIDTH: 415pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=553>Find Out About High Blood Sugar & Type 2 Diabetes</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; HEIGHT: 15.75pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl70 height=21>About High Blood Sugar</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #efefef; WIDTH: 132pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8" class=xl68 width=176></TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: #efefef; WIDTH: 415pt; BORDER-TOP: #ece9d8; BORDER-RIGHT: #3867a6 1pt solid" class=xl69 width=553>Find Out About How To Treat Type 2 Diabetes.


</TD></TR></TBODY></TABLE>

I may be crude, but I git 'er done.
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,882
Members
452,948
Latest member
Dupuhini

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