View Full Version : Getting runtime error from Range object that VBA Debugger shows as "String * -1" Type

Bob Boblaw
06-21-2018, 11:38 AM
I've upgraded my MacBook Pro and switched from Excel 2011 to 2016. I've been updating my VBA code to make it work again, but started to get a strange runtime error with a recent Excel software update. I trap the change event on a worksheet and pass the Target Range object, a Cell in my case to other functions. It seems to pass okay to some but is now throwing runtime error in another function. Oddly, the VBA debugger doesn't show it as a Range Object but as a "String * -1" It is all very strange and what use to work before just fine is now broken. I need help! Below is an image from the debugger.


06-22-2018, 10:18 AM
Could you be passing the Target argument byRef and those functions/macros be altering the variable? Step through the code with F8, including stepping through those functions/macros and watch when that variable changes its type/value.
Apart from that you could include a line such as:
Set myTarget = Target
and pass that variable to the functions/macros instead (not byRef) with the aim of keeping Target intact.

I don't work with Macs, but I do know there are significant differences between Mac VBA and Microsoft's.

Bob Boblaw
06-25-2018, 01:28 PM
Good suggestions, but it seemed to fix itself this morning. I do modify the Target, changing the font of certain characters in the cell text. The problem was in a sub I called, but my functions seemed ok, so I converted it to a function. I also added error trapping to that sub/function to see where in that sub/function the error was getting thrown. Things started to work again, so converted it back to a sub and it still worked, keeping the error handler. I also had problems saving edits to my add-in before (says it was read only) and that has stopped giving me problems too.