OK, this is probably a stupid-simple question, but WHY do you ever need to activate a worksheet (if you have assigned a variable name to that sheet and can refer to it using that name)?
The reason I'm asking: I'm trying to simply set the value of a named range (single cell, call it "OtherCell") on one worksheet (that I have set as "OtherSheet") equal to the value of another single-cell named range (call it "SourceCell") which is in ThisWorkbook. NOTE that OtherSheet is in a different (open) workbook (not ThisWorkbook). So I wrote something like this:
I get a runtime error 424 (object required) whenever I run this command. If, however, I simply go look at OtherSheet (making it the active sheet), then the command runs fine. So apparently (I'm guessing), I can't change a value in another workbook (other than ThisWorkbook) unless I first activate that worksheet (or workbook?).![]()
Please Login or Register to view this content.
So before I go edit all my code, I'm trying to understand:
• When do I have to activate a (not ThisWorkbook) worksheet or workbook when running a macro?
• What can (and can't) I do to or with the "other" worksheet if it's not activated?
• Can I read / copy data from another workbook without activating it?
• Can I sort data in another workbook without activating it?
• If I activate the "other" workbook or worksheet, do I then need to re-activate ThisWorkbook before I can make changes to it (via the macro)?
I understand that this OUGHT to be a very basic topic, but all I can find in any documentation is HOW to activate a worksheet. No one ever seems to explain WHY / WHEN you need to activate a worksheet! So if someone can please enlighten me, I'd appreciate it. Thanks!
Bookmarks