Johnny C
Well-known Member
- Joined
- Nov 7, 2006
- Messages
- 1,069
- Office Version
- 365
- Platform
- Windows
I've got a variable called strShtName, declared as a string.
It's set once at the top of a loop.
Way down in the loop, a function is called
Half way through the function, the value of strShtName is changed on the line in red below. There's a watch on the variable set to break when the value of strShtName changes. if I move the yellow cursor back up a line and F8 to step through it changes again,
The function works fine, but why is it altering the value of the parameter used to call it?
Even weirder, it worked fine, it's worked fine for the last year. I changed code somewhere else in the loop and it started doing this.
This is the function.
TIA
It's set once at the top of a loop.
Way down in the loop, a function is called
Code:
If TblShapeExists(strShtName) Is Nothing Then
Half way through the function, the value of strShtName is changed on the line in red below. There's a watch on the variable set to break when the value of strShtName changes. if I move the yellow cursor back up a line and F8 to step through it changes again,
The function works fine, but why is it altering the value of the parameter used to call it?
Even weirder, it worked fine, it's worked fine for the last year. I changed code somewhere else in the loop and it started doing this.
This is the function.
Code:
Function TblShapeExists(strTblName$) As Shape
If InStr(1, strTblName, "table:") > 0 Then
If InStr(1, strTblName, ",") > 0 Then strTblName = Left(strTblName, InStr(1, strTblName, ",") - 1)
strTblName = Replace(strTblName, " table: ", "")
If InStr(1, strTblName, " ") > 0 Then strTblName = Left(strTblName, InStr(1, strTblName, " ") - 1)
End If
[COLOR="#FF0000"]strTblName = "Table: " & Trim(strTblName)[/COLOR]
On Error Resume Next
Set TblShapeExists = ActiveSheet.Shapes(strTblName)
On Error GoTo 0
End Function
TIA