Type 13 Mismatch Error from Reference Error

Whylucky

New Member
Joined
Sep 24, 2013
Messages
39
Hi All,

I have the below code which looks to see if a certain cell contains a phrase, either bearing or figure. However since this cell is a linked value there is a chance that an error (#Ref!) will show instead. I thought my code would search for the error and if it did not exist would move on, but instead it gives the Type Mismatch 13 Error. I have tried rearranging the code but the error still comes up. Does anyone have any suggestions on making this work? Any help would be greatly appreciated.

Code:
If Range("R" + CStr(g)).Value = CVErr(xlErrRef) Then        
Broken = True
    Else
        If InStr(Range("BC" + CStr(g)).Value, "Figure") Then
            Figure = True
            Broken = False
        ElseIf InStr(Range("BC" + CStr(g)).Value, "Bearing") Then
            Figure = False
            Broken = False
            If Range("R" + CStr(g)).Value = CVErr(xlErrRef) Then
                Broken = True
            End If
        End If
    End If

Regards,
Whylucky
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
a little trick, use '&' for string concatenation rather than '+' and it will automatically convert the numbers.

Use the iserror function to determine if a cell contains an error.

try this:
Code:
If IsError(Range("R" & g).Value) Then
    Broken = True
Else
    If InStr(Range("BC" & g).Value, "Figure") Then
        Figure = True
        Broken = False
    ElseIf InStr(Range("BC" & g).Value, "Bearing") Then
        Figure = False
        Broken = False
        If IsError(Range("R" & g).Value) Then
            Broken = True
        End If
    End If
End If
 
Upvote 0

Forum statistics

Threads
1,215,799
Messages
6,126,976
Members
449,351
Latest member
Sylvine

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top