PC Review


Reply
Thread Tools Rate Thread

Adding macro buttons to new worksheets

 
 
=?Utf-8?B?bm9zcGFtaW5saWNo?=
Guest
Posts: n/a
 
      13th Nov 2006
I have a workbook with 3 sheets, Budget, Extract and Summary where Summary
contains a Pivot Table which is macro generated from data in the Budget and
Extract sheets.

I've got macro buttons (auto-shapes) on the 3 sheets and I want to add macro
buttons to the new sheet which is generated when a cell is double-clicked in
a pivot table (to show the detail behind the summary).

These sheets will always be called Sheet1, Sheet2 etc.

Is it possible to run a macro automatically each time a new worksheet which
begins with "Sheet" is generated? If so, how do I do this please as I'm stuck?

Thanks a lot in anticipation.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q2hhcmxlcyBDaGlja2VyaW5n?=
Guest
Posts: n/a
 
      13th Nov 2006
In the VBE, find the "ThisWorkbook" object, then in the left combobox, select
"Workbook", in the right combobox select "NewSheet". This should add a
routine that looks like this:
Private Sub Workbook_NewSheet(ByVal Sh As Object)

End Sub

change it to look like this:
Private Sub Workbook_NewSheet(ByVal Sh As Object)
Call YourMacro
End Sub

This will run the macro named "YourMacro" everytime a sheet is added to your
workbook
--
Charles Chickering

"A good example is twice the value of good advice."


"nospaminlich" wrote:

> I have a workbook with 3 sheets, Budget, Extract and Summary where Summary
> contains a Pivot Table which is macro generated from data in the Budget and
> Extract sheets.
>
> I've got macro buttons (auto-shapes) on the 3 sheets and I want to add macro
> buttons to the new sheet which is generated when a cell is double-clicked in
> a pivot table (to show the detail behind the summary).
>
> These sheets will always be called Sheet1, Sheet2 etc.
>
> Is it possible to run a macro automatically each time a new worksheet which
> begins with "Sheet" is generated? If so, how do I do this please as I'm stuck?
>
> Thanks a lot in anticipation.

 
Reply With Quote
 
=?Utf-8?B?bm9zcGFtaW5saWNo?=
Guest
Posts: n/a
 
      13th Nov 2006
Many thanks Charles - that's excellent.

Thanks again
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a macro to copy worksheets Gregc. Microsoft Excel Programming 0 30th Jan 2008 07:27 AM
VBA / Macro for creating new worksheets and new columns from existing worksheets webby2006 Microsoft Excel Programming 3 25th Jul 2006 03:38 PM
Customising Macro Buttons, Adding an image in excel =?Utf-8?B?QmF6?= Microsoft Excel New Users 1 3rd Jul 2005 05:22 PM
Adding & Naming Worksheets in a macro John Microsoft Excel Misc 3 5th Mar 2004 05:13 PM
Adding buttons and connect macro Bob Phillips Microsoft Excel Programming 4 20th Aug 2003 06:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:44 AM.