Trying to assign macro short from VBA

jack29

New Member
Joined
Apr 28, 2021
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Hi ,

I wanted to assign a permanent Shortcut key in VBA. rather than adding from macros --> options every day. likewise, I searched across and added this code. when I click Ctrl+Shift+Y, in should reset filter or clear some fields etc.. but that is failing to get performed. Please kindly let me know how to correct this. I have a few more macros every day it's difficult to assign the shortcut keys for each and also do not want to save the file as XLSM, so usually I would prefer to keep it as XLSX and in One Drive.

below is code

Option Explicit
Public Sub CreateShortcut()
Application.OnKey "+^{Y}", "Clear_Rule_Filter"
End Sub

Sub Clear_Rule_Filter()
'
' Clear_Rule_Filter Macro
'
'
ActiveSheet.Range("$I$1:$N$4000").AutoFilter Field:=6
End Sub
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi ,

I did not know after writing this code I had not run the code using the play or compile button instead was trying to directly hit ctrl+shift+Y in my excel but it failed to clear up. However, after running the code once, it gets assigned then it started working. need to see this after restart if i just import macro would it assign or again need to compile.

Thanks,
Sukhen (Self Solved)
 
Upvote 0
Solution

Forum statistics

Threads
1,215,569
Messages
6,125,600
Members
449,238
Latest member
wcbyers

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