Personal Macro Workbook mystery

Misca

Well-known Member
Joined
Aug 12, 2009
Messages
1,749
Office Version
  1. 365
Platform
  1. Windows
I've got a macro stored in my Personal Macro Workbook. What it does is basically open a workbook and add a new row to the existing table.

It works perfectly if I run it using any other way but using the shortcut keys. The macro still opens the workbook using the shortcut keys but it doesn't make any changes to the worksheet.

I have no idea why this happens or how to solve this. Any help would be appreciated for I'd prefer to use the keys to run it.
 
Without knowing exactly what your code is, what workbooks are open & what is active at any moment in time. It's very difficult to help, but I have never encountered the problem you are getting & suspect that it has something to do with using select.
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Thank you for your help.

I've tried commenting the ".Select" part and everything else I can think of. No effect: The code runs perfectly as long as it's not triggered through keyboard shortcuts.

Actually, I've managed to locate the problem. It seems to have something to do with the Shift key in the keyboard shortcut. If I set it to Ctrl + "e" it runs perfectly to the end. But if there's the Shift key in the shortcut the code runs to the Set WB row and ends on that line. Even if that line is put inside an if statement with End If being the very next line after that.

I even tried adding simple error handlers to the code: No effect whatsoever. The code does not error. It just stops running at the Workbooks.Open line as if it was the last line of code. If I disable the events at the start of the code it never reaches the end of the code where they'd be enabled again. And it doesn't matter if I set the WB to a variable or not: Workbooks.Open is the last line of code it reads when using the Shift in the keyboard shortcut.

I'm pretty happy with the code running perfectly from the keyboard shortcut without the Shift key but it would be interesting to know what it is in the Shift key that changes the code behavior.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,749
Members
448,989
Latest member
mariah3

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