0:00
In this video, we'll add a custom command to the right-click context menu in Excel using VBA
0:05
First, press Alt-F11 to open the VBA editor. Insert a new model where you can write your code
0:11
Write the VBA code into the module as shown on the screen. Press F5 to run the Add Context Menu macro
0:18
Right-click on any cell in Excel, and you should see the BrainBell option in the context menu
0:23
Each time you run the macro, it adds another BrainBell option to the context menu
0:27
To prevent duplicates, we must first remove the BrainBell item from the context menu
0:31
even if it doesn't already exist. We've added another subroutine, Remove BrainBell Menu
0:36
which removes a context menu item by its name. Run Remove BrainBell Menu multiple times until all extra BrainBell options are removed from the context menu
0:45
Next, modify the code as shown on the screen. This way, even if you accidentally run the Add Context Menu macro multiple times
0:53
it won't add duplicate options to the context menu. If you prefer not to add the custom menu item manually each time
0:59
you can use the Workbook Open event. This will automatically initialize the custom context menu whenever you open the workbook
1:06
In the VBA editor, double-click the This Workbook object to open its code editor
1:10
and insert the code as shown in the video. Close and reopen the workbook
1:14
You'll see the custom option automatically added to the context menu without manually running the macro
1:19
Thanks for watching. Please like, share, and subscribe for more helpful videos