Vbs keyboard activated userform listbox

DenniBrink

New Member
Joined
Jul 31, 2016
Messages
46
Hello everyone! I seeking guidance on how to create a keyboard activated macro for a userform navigation worksheet listbox. I want to be able to access the userform anywhere in the workbook with the Control + M keyboard command.

I have created the Userform listbox and dynamic range name (WorksheetLists). I need help on where in my workbook the subroutine should be placed, how it should be activated, and associated with the keyboard activated macro.
 
Hi! I want a list of worksheets names I can solicit with a keystroke command to enable workbook navigation. Can you help?
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Have you populated the listbox with the sheet names using the code suggested earlier?

If you have then it should be straightforward to use it to navigate to a worksheet.

All you would need would be something like this.
Code:
If ListBox1.ListIndex<>-1 Then
    Sheets(ListBox1.Value).Activate
End If
 
Upvote 0
That's my suggestion also if that's what you want.
Have you populated the listbox with the sheet names using the code suggested earlier?

If you have then it should be straightforward to use it to navigate to a worksheet.

All you would need would be something like this.
Code:
If ListBox1.ListIndex<>-1 Then
    Sheets(ListBox1.Value).Activate
End If
 
Upvote 0
Option Explicit Module 1: This is how the Userform is enabled and made available for macro implementation
Sub Userform_Show() with keystroke Cntrl + Shift + M.
Userform1.Show
End Sub

Private Sub CommandButton1_Click() 'Go To Sheets Button'
Dim i As Integer, sht As String
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
sht = ListBox1.Text Change
End If
Next i
Sheets(sht).Activate
End
End Sub

Private Sub CommandButton2_Click() 'Cancel Button'
Unload Userform1
End Sub

Private Sub ListBox1_Click()

End Sub

Private Sub UserForm_Click()

End Sub

Additionally, I discovered my Row Source properties had incorrect worksheetnames. Now I am happy to report the Userform works perfectly.

Thank you everyone for all your help! :)
 
Upvote 0
Glad we were able to help you. Come back here to Mr. Excel next time you need additional assistance.
Option Explicit Module 1: This is how the Userform is enabled and made available for macro implementation
Sub Userform_Show() with keystroke Cntrl + Shift + M.
Userform1.Show
End Sub

Private Sub CommandButton1_Click() 'Go To Sheets Button'
Dim i As Integer, sht As String
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
sht = ListBox1.Text Change
End If
Next i
Sheets(sht).Activate
End
End Sub

Private Sub CommandButton2_Click() 'Cancel Button'
Unload Userform1
End Sub

Private Sub ListBox1_Click()

End Sub

Private Sub UserForm_Click()

End Sub

Additionally, I discovered my Row Source properties had incorrect worksheetnames. Now I am happy to report the Userform works perfectly.

Thank you everyone for all your help! :)
 
Upvote 0

Forum statistics

Threads
1,216,361
Messages
6,130,180
Members
449,563
Latest member
Suz0718

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top