It has been a while since I've used VBA and I'm wondering what I've forgotten.
If I call a function from Excel with a range of cells, am I able to alter the values of those cells from within the function that I've written?
Let's say I have the following function:
Function DoStuff(rng As Range) As String
It is being called from cell P4 with the range of cells being B2:L9.
Somewhere in there I have the following piece of code:
rng.Cells(iRow, jCol).Value = " "
where iRow = 1 and jCol = 1. I can determine via debug messages that they correctly point to B2 and that prior to this assignment rng.Cells(iRow, jCol).Value = "H".
However, when I try to step past the above statement in the debugger, it goes to Never Never Land (ie, becomes unresponsive). When I simply execute it from the worksheet without debugging, it returns #VALUE!.
What obvious error am I making in trying to assign a value? Is there some switch I need to set first so that I can assign values to the passed range? I have tried passing it both ByVal and ByRef.
Bookmarks