Run Time Error 13 Type Mismatch

Benzoli7

Board Regular
Joined
Jan 11, 2010
Messages
136
I get the following error when my macro runs the following line of code.

HTML:
If Range("AA:AA").Value = "NEW" Then

Here is the whole block of code that contains the above line.

HTML:
'Checks for new carrier lane
    Range("AA7").Select
    ActiveCell.FormulaR1C1 = _
        "=IF(COUNTIF('Current Ranking'!C[-25],'Rate Comparison'!RC[-15])>0,1,""NEW"")"
    Range("AA7").AutoFill Destination:=Range("AA7:AA" & LR), Type:=xlFillDefault
     Calculate
     Range("AA:AA").Select
     Selection.copy
     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

     
'Adds new lanes to proposed ranking sheet
 
   
   Sheets("Rate Comparison").Activate
   If Range("AA:AA").Value = "NEW" Then
    Range("A6").Select
    Range("A6").AutoFilter
    Range("A6").AutoFilter Field:=27, _
        Criteria1:="=New"
    Range("A7").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.SpecialCells(xlCellTypeVisible).copy
    Sheets("Proposed Ranking").Select
    FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
    Range("C" & FinalRow + 1).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("Rate Comparison").Select
    Range("C7").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.SpecialCells(xlCellTypeVisible).copy
    Sheets("Proposed Ranking").Select
    FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
    Range("E" & FinalRow + 1).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("Rate Comparison").Select
    Range("D7:J7").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.SpecialCells(xlCellTypeVisible).copy
    Sheets("Proposed Ranking").Select
    FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
    Range("F" & FinalRow + 1).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("Rate Comparison").Select
    Range("Q7:R7").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.SpecialCells(xlCellTypeVisible).copy
    Sheets("Proposed Ranking").Select
    FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
    Range("Q" & FinalRow + 1).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("Rate Comparison").Select
    Range("B7").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.SpecialCells(xlCellTypeVisible).copy
    Sheets("Proposed Ranking").Select
    FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
    Range("O" & FinalRow + 1).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("Rate Comparison").Select
    Range("K7:L7").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.SpecialCells(xlCellTypeVisible).copy
    Sheets("Proposed Ranking").Select
    FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
    Range("A" & FinalRow + 1).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
   Sheets("Rate Comparison").Select
   Range("A6").AutoFilter
End If

Can anyone tell what I'm doing wrong here.

Thanks so much.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Maybe

Code:
If IsNumeric(Application.Match("NEW", Range("AA:AA").Value, 0)) Then
 
Upvote 0
Range("AA:AA") is a column. You can't compare a column of values to just one value "New".

I'm not sure what you are trying to do so I can't suggest a solution.

EDIT: Oh i see now. Try this...
Code:
If Not Range("AA:AA").Find("New", , , xlWhole, , , False) Is Nothing Then
 
Last edited:
Upvote 0
Run a for loop in vba to search for "new" on a line by line basis, or use the find() or search() function. I am not sure how to use those.
 
Upvote 0
Thanks AlphaFrog. That worked perfectly. Do you mind explaining a little bit about what is going on there?
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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