Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2004, 10:26 AM
Authorized User
 
Join Date: Sep 2003
Location: Ipswich UK, , United Kingdom.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MattLeek
Default If Sheet Is Selected

Hi, its me again!

I dont know much Excel VBA but i am getting through by Reading Macros. But i now need to display a message when the user selects a sheet. I've go as far as getting a Private Sub up for when sheets are selected but im stuck on how to see which sheet it is. There is an argument "ByVal Target As Range" but thats about it.

Sorry to keep bothering this forum!
Thanks

Matthew Leek
__________________
Thanks,
Matthew
 
Old March 24th, 2004, 11:49 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Try using the Worksheet_Activate event. Just open up the VB macro editor and from the project explorer, choose the sheet for which you want to display the message, and paste in a sub like this:
Code:
Private Sub Worksheet_Activate()
    MsgBox "hello from " & Me.Name
End Sub
BTW its no bother - ask as many questions as you like.

rgds
Phil
 
Old March 24th, 2004, 01:03 PM
Authorized User
 
Join Date: Sep 2003
Location: Ipswich UK, , United Kingdom.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MattLeek
Default

Thanks for the help,

and ill keep the question thing in mind! :D



Matthew Leek
 
Old March 25th, 2004, 12:53 PM
Authorized User
 
Join Date: Sep 2003
Location: Ipswich UK, , United Kingdom.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MattLeek
Default

Hi again, just one more thing i promise! How would i find out what the previous sheet was?

Matthew Leek
 
Old March 26th, 2004, 05:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

I think you would have to put some code in the Worksheet_Deactivate event to store the name of the worksheet that was deactivated in a module level variable, which you can then access from the Worksheet_Activate event of the next sheet.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Workbook,Copy Sheet,Move Sheet, Close/Save ptrussell2009 Excel VBA 0 June 13th, 2008 02:28 PM
access function in data sheet(another sheet) jani Excel VBA 1 May 21st, 2008 07:15 PM
Sheet Tab Neal Excel VBA 0 May 24th, 2006 10:12 AM
SPREAD SHEET pallone Javascript How-To 12 June 27th, 2005 10:36 AM
syntax error on <option selected="selected"> hamid HTML Code Clinic 1 October 13th, 2004 09:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.