OxfordCurmudgeon
New Member
- Joined
- Oct 24, 2023
- Messages
- 14
- Office Version
- 2010
- 2003 or older
- Platform
- Windows
How can code work when it's not running? When it's in the Immediate window.
I evaluate this code in the Immediate window
?Range("ShiftsOrderedDataArea").Cells(1,1).Value
and it retrieves the contents of the cell. I then put my cursor on the start of a subroutine and press F8 (Step Into). The Private Sub ... line gets highlighted in yellow. I go back to the Immediate window and execute the same line of code (no changes) and I get
Run-time error '1004': Application-defined or object-defined error
I click OK to clear the error message, then click Reset under the Run dropdown menu, then go back to the Immediate window and run that line of code again. It works as expected.
The named range is defined in the same workbook as my code:
I assume this is another newbie mistake. Can anyone point me in the right direction?
I evaluate this code in the Immediate window
?Range("ShiftsOrderedDataArea").Cells(1,1).Value
and it retrieves the contents of the cell. I then put my cursor on the start of a subroutine and press F8 (Step Into). The Private Sub ... line gets highlighted in yellow. I go back to the Immediate window and execute the same line of code (no changes) and I get
Run-time error '1004': Application-defined or object-defined error
I click OK to clear the error message, then click Reset under the Run dropdown menu, then go back to the Immediate window and run that line of code again. It works as expected.
The named range is defined in the same workbook as my code:
I assume this is another newbie mistake. Can anyone point me in the right direction?