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
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