Forum Discussion
waygar
Nov 10, 2022Brass Contributor
To run a macro on another excel sheet with a different number of rows
Hi, I recorded a macro but when I try to use it on another spreadsheet with a different number of rows I get Error 9. Help I am new to this.
waygar
Jan 11, 2023Brass Contributor
Yes
HansVogelaar
Jan 11, 2023MVP
In that case, I have no idea why it doesn't work, but you could try
Set wbkClass = ActiveWorkbook
as in your original code.
- waygarJan 11, 2023Brass ContributorOk I now know what the cause is - assigning a shortcut key to the macro.
Even with your code, assigning a shortcut key such as CTRL SHFT U makes the code only work if run twice. I don't know why! - HansVogelaarJan 11, 2023MVP
I cannot explain that.
P.S. This discussion has become very long and awkward to navigate.
If you have a new question unrelated to the current discussion, would you be so kind to start a new discussion? Thanks in advance.
- waygarJan 11, 2023Brass ContributorSorry Hans
I did have a typo and your code now works in PERSONAL.XLSB
Why my code needs the dual run is a mystery?