Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Detect New Worksheet being added

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!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Detect New Worksheet being added

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!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Detect New Worksheet being added

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!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Detect New Worksheet being added

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
automatically appending newly added data on worksheet to a master list worksheet tabylee via OfficeKB.com Links and Linking in Excel 0 December 17th 09 04:24 PM
Can I detect a KEYDOWN event while in a worksheet Ken Soenen Excel Programming 1 December 15th 05 01:17 AM
To detect changes in a worksheet Sinus Log Excel Programming 4 December 8th 05 07:43 AM
how to detect added or deleted rows in compare helpwithXL Excel Programming 1 April 29th 05 01:48 PM
detect worksheet mike allen Excel Programming 2 October 28th 03 10:33 PM


All times are GMT +1. The time now is 04:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"