Showing posts with label insert cell macro. Show all posts
Showing posts with label insert cell macro. Show all posts

Sunday, July 31, 2016

Problem Solving In Excel The macro may not be available in this workbook or all macros may be diabled


I get the following error message while trying to run some code I've developed. I just made some changes to this subroutine so odds are that it's missing.

The first thing I do is check if other macros are working. I have one that inserts a blank cell and shifts all the other cells down within the active column. I try it and it works.

I did move the macro from ThisWorkbook to a module so it can be called by other routines.

I press Alt+F11 and search for the string in the error message "book.on"


Private Sub Workbook_Activate()
 Application.OnKey "^+{RIGHT}", "ThisWorkbook.OnCtrlShiftRightArrowKeyPress"
 Application.OnKey "^+{LEFT}", "ThisWorkbook.OnCtrlShiftLeftArrowKeyPress"

End Sub


I modify the code to the following:

 Application.OnKey "^+{RIGHT}", "OnCtrlShiftLeftArrowKeyPress"

I run the code via F8.

and then try the function again. It fails with the same message. I check the change I made and see that I did it wrong and fix it. Another test and the the fix works.

I save and back up the code.