Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Self-updating shortcut menu

Hello, I hope someone can help me with this, PLEASE.

I have built a program that when the user double clicks in any sheet, a shortcut menu is displayed listing all of the sheet names in the active workbook. This much I have and works great.

But now, I need the ability to capture which sheet name the user clicks on the shortcut menu and then take the user to the SAME ROW on the sheet name the user clicked.

The number and names of the sheets varies all the time, so the shortcut menu must be dynamic.

For example, user is in Sheet5 and double clicks on row 455, the shortcut menu is displayed and the user selects Sheet89. The program takes the user to sheet89 and selects row 455.

How can I do this?

As I said my program already captures the sheet names and puts them into a menu, but how do I determine which sheet name the user clicked? My code so far follows:

Dim arrSheets() As Variant
Dim objSheet As Worksheet
Dim cmdBar As CommandBar
Dim intX As Integer
Dim varItem As Variant
Dim strButtonName As String

For Each objSheet In ThisWorkbook.Sheets
If objSheet.Visible = True Then
intX = intX + 1
ReDim Preserve arrSheets(intX)
arrSheets(intX) = objSheet.Name
End If
Next

For intX = 1 To UBound(arrSheets)
strButtonName = arrSheets(intX)
Set cmdBar = Application.CommandBars(cstrShortCutMenu4)
With cmdBar
.Controls.Add Type:=msoControlButton
.Controls(intX).Caption = strButtonName
.Controls(intX).OnAction = "GOTO_Program"
End With
Next intX

Your example code would be most appreciated. Thanks in advance...

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Self-updating shortcut menu

Public Sub GOTO_Program()
Dim rw as Long, sName as String
rw = Activecell.row
sName = CommandBars.ActionControl.Caption
worksheets(sName).Select
cells(rw,1).Select
' or Rows(rw).Select
End sub

--
Regards,
Tom Ogilvy

wall wrote in message
...
Hello, I hope someone can help me with this, PLEASE.

I have built a program that when the user double clicks in any sheet, a

shortcut menu is displayed listing all of the sheet names in the active
workbook. This much I have and works great.

But now, I need the ability to capture which sheet name the user clicks on

the shortcut menu and then take the user to the SAME ROW on the sheet name
the user clicked.

The number and names of the sheets varies all the time, so the shortcut

menu must be dynamic.

For example, user is in Sheet5 and double clicks on row 455, the shortcut

menu is displayed and the user selects Sheet89. The program takes the user
to sheet89 and selects row 455.

How can I do this?

As I said my program already captures the sheet names and puts them into a

menu, but how do I determine which sheet name the user clicked? My code so
far follows:

Dim arrSheets() As Variant
Dim objSheet As Worksheet
Dim cmdBar As CommandBar
Dim intX As Integer
Dim varItem As Variant
Dim strButtonName As String

For Each objSheet In ThisWorkbook.Sheets
If objSheet.Visible = True Then
intX = intX + 1
ReDim Preserve arrSheets(intX)
arrSheets(intX) = objSheet.Name
End If
Next

For intX = 1 To UBound(arrSheets)
strButtonName = arrSheets(intX)
Set cmdBar = Application.CommandBars(cstrShortCutMenu4)
With cmdBar
.Controls.Add Type:=msoControlButton
.Controls(intX).Caption = strButtonName
.Controls(intX).OnAction = "GOTO_Program"
End With
Next intX

Your example code would be most appreciated. Thanks in advance...



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Self-updating shortcut menu

Amazing

Thanks Tom.
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
What is a shortcut menu? Jeffry Excel Discussion (Misc queries) 4 May 4th 09 04:03 PM
Popup Menu / Shortcut Menu Dale Fye Excel Discussion (Misc queries) 2 October 12th 07 12:57 AM
shortcut menu Javed Excel Discussion (Misc queries) 1 December 6th 04 09:28 PM
Shortcut menu on worksheet tab David Excel Programming 1 November 3rd 03 02:15 PM
shortcut for menu Douvid Excel Programming 1 July 28th 03 06:04 PM


All times are GMT +1. The time now is 04:55 PM.

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"