VBA Range.Find "Type Mismatch"

Tenquis

New Member
Joined
Dec 27, 2013
Messages
1
Hi,

I am new to this forum and am having trouble with a type mismatch on the Range.Find function.
It is finding a link in the text it is searching and giving me a type mismatch.

Here is my code :

Code:
Dim SearchSheet As Worksheet


Set SearchSheet = ThisWorkbook.Worksheets("Ticket Finder")




    Dim txt As String
    Dim i As Integer
    Dim CellRange As Integer
    Dim FullText As Variant
    Dim out As Variant 'String
    Dim OutCell As Integer
    Dim DupeRange As Integer
    Dim OutSheet As Worksheet
    
   Dim xl0 As New Excel.Application
   Dim xlw As New Excel.Workbook
   
   OutCell = 2


''File Open/Close Operations
    Set xlw = xl0.Workbooks.Open("name of output file")
    Set OutSheet = xlw.Worksheets("Sheet1")
    For CellRange = 2 To 2000
'If CDate(SearchSheet.Range("F" & CellRange).Value) > CDate("12/22 5:00 AM") Then
        txt = SearchSheet.Range("V" & CellRange)
         FullText = Split(txt, " ")
        For i = 0 To UBound(FullText)
        out = FullText(i)
        
        With OutSheet.Range("A1:A2000")
            Set C = .Find(out, LookIn:=xlValues)
            Set SearchSheet = ThisWorkbook.Worksheets("Ticket Finder")
            If Not C Is Nothing Then
                If SearchSheet.Range("M" & CellRange).Value = "Model#" Then
                    xlw.Worksheets("Sheet1").Range("B" & C.Row).Value = xlw.Worksheets("Sheet1").Range("B" & C.Row).Value + 1
                End If




            End If
            If C Is Nothing Then
                If SearchSheet.Range("M" & CellRange).Value = "Model#" Then
                    xlw.Worksheets("Sheet1").Range("A" & OutCell).Value = out
                    xlw.Worksheets("Sheet1").Range("B" & OutCell).Value = 1
                    OutCell = OutCell + 1
                 End If
            End If
        End With
        
        
        Next i
'End If
    Next CellRange
   xlw.Save
   xlw.Close

PS: Some values have been changed for copyright of internal office purposes, but other than that this is the code I am running. The error only appears when I search a range that contains an extra long link...
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,214,636
Messages
6,120,669
Members
448,977
Latest member
moonlight6

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