Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Action on sheet Selection
Hello everyone, Im back for another probably easy question. How would get excel to preform a certain action, or macro, when a specific shee is selected? Thanks again everyone -- jpizzl ----------------------------------------------------------------------- jpizzle's Profile: http://www.excelforum.com/member.php...fo&userid=2392 View this thread: http://www.excelforum.com/showthread.php?threadid=37699 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Action on sheet Selection
thank you sir -- jpizzl ----------------------------------------------------------------------- jpizzle's Profile: http://www.excelforum.com/member.php...fo&userid=2392 View this thread: http://www.excelforum.com/showthread.php?threadid=37699 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Action on sheet Selection
jpizzle Wrote: thank you sir. jpizzle Glad to be of help. Dave -- Piranha ------------------------------------------------------------------------ Piranha's Profile: http://www.excelforum.com/member.php...o&userid=20435 View this thread: http://www.excelforum.com/showthread...hreadid=376995 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Action on sheet Selection
Dear Sir, Try this: Place the code below in "ThisWorkbook" Module of your workbook Private Sub Workbook_SheetActivate(ByVal Sh As Object) Dim SheetName As String SheetName = "Sheet1" If Sh.Name = SheetName Then 'Your code goes here MsgBox "You Selected Sheet: " & Sh.Name End If End Sub What you need to do: Replace SheetName with the name of the sheet you want to capture and place you code where it says "Your Code Here". Remenber to remove the msgbox instruction I placed for ilustration. What it does: When you select Sheet1 (Name I selected for SheetName) will display a message with the name of the selected sheet. How it works: When you select a sheet the "Workbook_SheetActivate" event fires. Excel passes the sheet name through the variable "Sh". SheetName = "Sheet1" -- Here you replace "Sheet1" with the name of the sheet you want to capture. If Sh.Name = SheetName Then 'PLACE YOUR CODE HERE End If Please, let me know if that solve your ploblem. regards. Juan Carlos -- cscorp ------------------------------------------------------------------------ cscorp's Profile: http://www.excelforum.com/member.php...o&userid=24015 View this thread: http://www.excelforum.com/showthread...hreadid=376995 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Action on sheet Selection
Previous post is better, put the code in the specific sheet's module, that
way if the user changes the sheet name, it will not cause the code to fail. Bill "cscorp" wrote in message ... Dear Sir, Try this: Place the code below in "ThisWorkbook" Module of your workbook Private Sub Workbook_SheetActivate(ByVal Sh As Object) Dim SheetName As String SheetName = "Sheet1" If Sh.Name = SheetName Then 'Your code goes here MsgBox "You Selected Sheet: " & Sh.Name End If End Sub What you need to do: Replace SheetName with the name of the sheet you want to capture and place you code where it says "Your Code Here". Remenber to remove the msgbox instruction I placed for ilustration. What it does: When you select Sheet1 (Name I selected for SheetName) will display a message with the name of the selected sheet. How it works: When you select a sheet the "Workbook_SheetActivate" event fires. Excel passes the sheet name through the variable "Sh". SheetName = "Sheet1" -- Here you replace "Sheet1" with the name of the sheet you want to capture. If Sh.Name = SheetName Then 'PLACE YOUR CODE HERE End If Please, let me know if that solve your ploblem. regards. Juan Carlos -- cscorp ------------------------------------------------------------------------ cscorp's Profile: http://www.excelforum.com/member.php...o&userid=24015 View this thread: http://www.excelforum.com/showthread...hreadid=376995 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy Sheet action very slow | Excel Discussion (Misc queries) | |||
Action on sheet Selection | Excel Programming | |||
How to action on Open Sheet | Excel Programming | |||
onClick action from cell selection | Excel Programming |