I'm improving my code's readability by inserting Named ranges into an existing, working macro. The problem is that Named ranges seem to act differently in different macro statements and I can't figure out how to use them so they work.
My original code is:
and I want to replace
with a named range Chapter_Primary, where the range of Chapter_Primary that has just one cell, namely 'Instructions and Scratch Pad'!$B123, per the following screen-capture:
Named Range.JPG
I've searched online for ways to implement this and saw, for a one-cell Named Variable, that I can use
. Just to be cautious, I inserted a print statement immediately before my original code, so my code now reads
When I execute the code, MsgBox displays the proper chapter, but the calculation changes from 89% to 0%; i.e., the expression
is never true. Why would Range("Chapter_Primary") work with MsgBox but not COUNTIF?
As an alternative, I also tried replacing
with
, so my code became
This would not execute, and the debugger would highlight this line of code.
How can I use the Named Range Chapter_Primary so the code works?
To help, I have attached the file.
I also want to replace the code
with the Named Range Chapters, so if your answer does not also apply to this situation, I would appreciate your help with this next step.
Bookmarks