Forum

VBA userform Comman...
 
Notifications
Clear all

VBA userform Commandbutton1 shortcut key

4 Posts
2 Users
0 Reactions
147 Views
(@stevenbehr1)
Posts: 92
Estimable Member
Topic starter
 

Hi,

 

In VBA userform I created a CommandButton1_Click which as a macro program behind it.

I have been trying to create a shortcut key like F9 so that when I run the module and complete various task, I can then hit F9 to enable CommandButton1_Click so that whatever the program behind it completes the data.

 

Thanks

 

Steve

 
Posted : 25/05/2020 1:07 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Steve,

What you're trying to do isn't totally clear and without your workbook again I can't see any code or the form.

Why not just create a sub that the command button calls, and then create a shortcut to run the same sub?

Phil

 
Posted : 25/05/2020 3:11 am
(@stevenbehr1)
Posts: 92
Estimable Member
Topic starter
 

Hi Phil,

 

The database is too big but I figured this code out and works. But after looking into it, looks like there is no way of doing 

A F9 key to initialize the cboSelect, which is my advanced filter. if you can confirm this that would be great.

Private Sub Userform_Initialize()
Me.cboSelect.List = WorksheetFunction.Transpose(Sheet5.Range("AA5:AB5"))
With Phonelist1
With .cmdCode
    .Accelerator = "G"
    .Enabled = True
    End With
    End With
End Sub

 

Steve

 
Posted : 25/05/2020 11:18 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Steve,

What about this?

Sub InitSub
   Me.cboSelect.List = WorksheetFunction.Transpose(Sheet5.Range("AA5:AB5"))
   With Phonelist1
      With .cmdCode
         .Accelerator = "G"
         .Enabled = True
       End With
    End With
End Sub

Private Sub Userform_Initialize()
   InitSub
End Sub

Sub InitSubShortcut
   InitSub
End Sub

Modify the code as needed.

Then create a shortcut to the InitSubShortcut sub?

Cheers

Phil

 
Posted : 26/05/2020 3:25 am
Share: