Pivot Table Data format

L

Little Penny

I have a Pivot Table and of course when I double Click one of the
totals it fires up a new worksheet with my data. I have a Macro that
formats the worksheet the way I want it to look for printing. Is the a
way to fire up the macro when I double click one of the totals.


Thanks for your help
 
D

Debra Dalgleish

You could add code to the ThisWorkbook module, that will run when a new
sheet is added to the workbook. Check the first cell in the new sheet,
to see if it matches the first cell in the source data table.

For example, if the source data has Date as the first heading, this will
run a macro named FormatSheet:

Private Sub Workbook_NewSheet(ByVal Sh As Object)
If Sh.Cells(1, 1).Value = "Date" Then
FormatSheet
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top