PC Review


Reply
Thread Tools Rate Thread

Detect New Worksheet being added

 
 
=?Utf-8?B?c2hhcm9ubQ==?=
Guest
Posts: n/a
 
      26th Sep 2007
Hello,

Is there a way to detect if a user has created a new worksheet in a workbook?

Whenever a user has created a new sheet, I need to populate some cells on
the Master sheet (1st tab) plus reference the newly added worksheet from the
user.

Any suggesstions would be greatly appreciated. Thanks!

 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWF0dGhldyBQZmx1Z2Vy?=
Guest
Posts: n/a
 
      26th Sep 2007
Yes! Use a Workbook_NewSheet event. In the VBE, go to your project and find
the ThisWorkbook module in the Microsoft Excel Objects folder. Then enter:

Private Sub Workbook_NewSheet(ByVal Sh As Object)
'your code here using 'Sh' to reference the new sheet
End Sub

HTH,
Matthew Pfluger

"sharonm" wrote:

> Hello,
>
> Is there a way to detect if a user has created a new worksheet in a workbook?
>
> Whenever a user has created a new sheet, I need to populate some cells on
> the Master sheet (1st tab) plus reference the newly added worksheet from the
> user.
>
> Any suggesstions would be greatly appreciated. Thanks!
>

 
Reply With Quote
 
=?Utf-8?B?RlN0MQ==?=
Guest
Posts: n/a
 
      26th Sep 2007
hi
Private Sub Workbook_NewSheet(ByVal Sh As Object)
Sheets("sheet1").Range("B2").Value = "PSST!"
Sheets("sheet1").Range("B3").FormulaR1C1 = _
"Someone added a sheet."
Sheets("Sheet1").Range("B4").Value = _
Application.UserName 'pc name
' eviron("username")= network name
Sheets("sheet1").Range("B5").Value = Now()
Sheets("sheet1").Range("B6").Value = "Have a nice day. :-)"
End Sub

this is thisworkbook code.

regards
FSt1

"sharonm" wrote:

> Hello,
>
> Is there a way to detect if a user has created a new worksheet in a workbook?
>
> Whenever a user has created a new sheet, I need to populate some cells on
> the Master sheet (1st tab) plus reference the newly added worksheet from the
> user.
>
> Any suggesstions would be greatly appreciated. Thanks!
>

 
Reply With Quote
 
=?Utf-8?B?c2hhcm9ubQ==?=
Guest
Posts: n/a
 
      26th Sep 2007
Thanks to both of you!

Your suggesstions are great to detect when a user adds a sheet!

But, can this be modified some way to detect if a user copies an existing
sheet by Right Clicking on the name of the sheet, Selecting the sheet, and
check the Create Copy box.

Thanks!

"FSt1" wrote:

> hi
> Private Sub Workbook_NewSheet(ByVal Sh As Object)
> Sheets("sheet1").Range("B2").Value = "PSST!"
> Sheets("sheet1").Range("B3").FormulaR1C1 = _
> "Someone added a sheet."
> Sheets("Sheet1").Range("B4").Value = _
> Application.UserName 'pc name
> ' eviron("username")= network name
> Sheets("sheet1").Range("B5").Value = Now()
> Sheets("sheet1").Range("B6").Value = "Have a nice day. :-)"
> End Sub
>
> this is thisworkbook code.
>
> regards
> FSt1
>
> "sharonm" wrote:
>
> > Hello,
> >
> > Is there a way to detect if a user has created a new worksheet in a workbook?
> >
> > Whenever a user has created a new sheet, I need to populate some cells on
> > the Master sheet (1st tab) plus reference the newly added worksheet from the
> > user.
> >
> > Any suggesstions would be greatly appreciated. Thanks!
> >

 
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
how to detect added or deleted rows in compare helpwithXL Microsoft Excel Programming 1 29th Apr 2005 01:48 PM
How to detect when items are added to Combobox/Listbox Don Microsoft VB .NET 9 13th Apr 2005 08:45 PM
How to detect when a Component is added to a WebForm David Microsoft ASP .NET 0 9th Mar 2005 04:36 PM
How to detect when a dynamically added control is clicked who be dat? Microsoft ASP .NET 7 13th Jul 2004 02:21 PM
Re: Detect new record being added but not saved yet Hugh O'Neill Microsoft Access Forms 2 3rd Jul 2003 09:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:38 AM.