Help me figure out this Type Mismatch error

juanbolas

New Member
Joined
Dec 3, 2014
Messages
40
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm getting a Run time error `3 - Type Mismatch in my code and can't figure out why. It was working until I decided to put in in a function as I call it from several places.

Thanks in advance


VBA Code:
Function ProcessConversion(wsSource As Worksheet)

Dim cCell As Range
Dim vCell As String
Dim vCriteria As String
Dim vSearchFor As String
Set rawdata = wsSource.Range("A1")
Set rawdata = rawdata.Resize(wsSource.UsedRange.Rows.Count, wsSource.UsedRange.Columns.Count)

For Each cCriteria In ThisWorkbook.Sheets("Criteria").Range("rCriteria").Cells
    
    For Each cCell In rawdata
        vCell = cCell.Value    '' ERROR OCCURS HERE
        vCriteria = cCriteria.Value
        vSearchFor = "*" & vCriteria & "*"
            If vCell Like vSearchFor Then
                With ThisWorkbook.Sheets("BLANK").Range("A1").Offset(counter, ColumnDestination)
                    .Value = vCell
                    If Left(vCell, 2) = "6 " Then
                        .Value = Mid(vCell, 3, 256)
                    End If
                    .Replace what:=vCriteria, replacement:=""
                    .Value = WorksheetFunction.Trim(.Value)

                    If Asc(Left(.Value, 1)) = 10 Then RemoveFirstLine ThisWorkbook.Sheets("BLANK").Range("A1").Offset(counter, ColumnDestination)
                    counter = counter + 1
                End With
                Exit For
            End If

    Next
Next
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,215,547
Messages
6,125,461
Members
449,228
Latest member
moaz_cma

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