MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Dr. Watson - Ugggghhhhh!


Posted by Melanie Swarner on October 23, 2001 11:55 AM

I am getting a Dr. Watson error because of the following line of code:

ActiveCell = ActiveCell + LookupValue(Product, ProdList, Offset)

Here's what LookupValue does:
Function LookupValue(Product As String, ProdList As Range, Offset As Variant)
LookupValue = Application.VLookup(Product, ProdList, Offset, False)
End Function

The function works, because I'm using it all over in my code. It's just this line. If I comment it out, it's fine. I tried putting in a HoldCell variable to hold the contents of the ActiveCell and then add them together later and I still get the error. The error log means nothing to me.

Any ideas?


Posted by Damon Ostrander on October 25, 2001 12:21 PM

Hi Melanie,

There are several ways this can fail. The problem has to do with the use of the active cell rather than the selected cell. "Active" implies that the cell is currently activated, or will be when the user types on the keyboard. The instant a cell is activated macros are not allowed to run. So one possibility is that the cell has been activated. Another is that some other type of sheet is active and therefore no active cell exists. If it is the former I recommend you just change to using the selected cell:

Selection = Selection + LookupVal....

Happy computing.

Damon