Hi folks,
I have a puzzling problem. Some module code I've written as part of an Excel AddIn works sucessfully on one PC, but when the AddIn is installed on another PC (same version of Excel - 2002), it generates a Type Mismatch error.
Anyone got any ideas why?
The error is generated with the first IF statement in the code below.
Any advice or suggestions will be greatly appreciated.
Thanks!
Simon Wiles
simonjwiles@gmail.com
I have a puzzling problem. Some module code I've written as part of an Excel AddIn works sucessfully on one PC, but when the AddIn is installed on another PC (same version of Excel - 2002), it generates a Type Mismatch error.
Anyone got any ideas why?
The error is generated with the first IF statement in the code below.
Any advice or suggestions will be greatly appreciated.
Thanks!
Simon Wiles
simonjwiles@gmail.com
Code:
Dim r As Range, cell, iStart, iFinish As Variant
Dim StringHolder, As String, iCount As Integer
For Each cell In r
StringHolder = cell.Value
If InStr(1, StringHolder, "*", vbTextCompare) <> 0 And _
InStr(InStr(1, StringHolder, "*", vbTextCompare) + 1, StringHolder, "*", vbTextCompare) <> 0 Then
For iCount = Len(StringHolder) To InStr(1, StringHolder, "*", vbTextCompare) Step -1
If Mid(StringHolder, iCount, 1) = "*" And _
Mid(StringHolder, iCount + 1, 1) <> "*" Then
iStart = iCount + 1
End If
If Mid(StringHolder, iCount, 1) <> "*" And _
Mid(StringHolder, iCount + 1, 1) = "*" Then
iFinish = iCount + 1
End If
Next iCount
cell.Value = Left(StringHolder, iStart - 1) & Right(StringHolder, Len(StringHolder) - iFinish + 1)