Hi,
Is it just me, or is this normal? Does WITH not travel through a GOSUB routine?
I kept getting an "invalid or unqualified reference" error on a line where I used .cells(row, column).value in a Gosub routine. the keyword CELLS kept highlighting along with the pop-up error. I couldn't figure it out. I've used WITH, END WITH, and dot-references often. I fixed the error, but why it's fixed is bizarre...to me. I'll post a modified workbook if I need to, but I'll try to explain because maybe this is just some common thing I haven't come across.
So, normally a dot-anything reference needs a WITH and an END WITH.
This works:
This doesn't because there's no WITH / END WITH to qualify the dot-cells command:
So, I was surprised when this gave me the above error (highlighting the WITH's in red. The error in blue:
(In case you're thinking 'put the with/end with in the gosub', the actual code has more going on so having the WITH where it is makes sense...or I thought it did)
To me, the WITH should have traveled into the Gosub routine and the x=.cells should have worked. But it didn't.
Here's how I fixed it, but it was a shot in the dark, and I dont know why this works:
No more error. I had to re-state and essentially "nest" the WITH/END WITH to make it work.
But why?!?!
Totally confused.
Bookmarks