I was running my macro perfectly then all of a sudden the macro started to show runtime error 13' Type mismatch and I can't figure it out. The part that's always getting highlighted is:
If Cells(x, "E") >= Num1 And Cells(x, "E") <= Num2 Then
and I think I coded it correctly because my other macros are coded that way but for some reason this is not working.
Sub PPM()
Dim RawData As Worksheet
Dim MatchData As Worksheet
Set MatchData = Worksheets("MATCH")
Set Pastesheet = Worksheets("PASTE")
Pastesheet.Select
Pastesheet.Range("$A$3:$F$5000").Clear
MatchData.Select
Application.ScreenUpdating = False
Set Num1 = MatchData.Range("$I$3")
Set Num2 = MatchData.Range("$K$3")
Dim x As Long
For x = 6 To 5000
If Cells(x, "E") >= Num1 And Cells(x, "E") <= Num2 Then
Cells(x, "A").Resize(, 6).Copy
Pastesheet.Cells(Rows.Count, "A").End(xlUp).Offset(1).PasteSpecial _
xlPasteValuesAndNumberFormats
End If
Next x
Application.ScreenUpdating = True
Pastesheet.Select
MsgBox "Search Complete"
End Sub
x
when the error first happens? – Excel HeroCells(x, "E")
when you see the error? – Tim WilliamsCells(x, "E")
has a formula error like#N/A
or similar – Siddharth Rout