Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

code works on one PC, but generates 'type mismatch' on another

Status
Not open for further replies.

simonwles

Technical User
Apr 28, 2006
3
GB
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

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)
 
Check Tools, References for any MISSING references on the problem computer. Missing references can cause strange behaviour.
 
Thanks for your suggestion Ettienne. However, I'm sorry but I'm not sure what you mean by 'Tools, References'. I don't have a menu entry by that name, and can find no mention of it in the excel help files.

Can you point me in the right direction?

Thanks,

Simon
 
Tools>References in the VBE - NOT in excel

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top