Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error
Try
For c = 2 to 5961
If Match_Code = Trim(worksheets("Rates").cells(c, 13).Text) Then
Worksheets("Entry").Range("F8") = _
Worksheets("Rates").cells(c, 15)
End If
Next c
Is the data downloaded or pasted from the internet. It may contain hidden
characters that cause the problem.
For c = 2 to 5961
sStr = Trim(worksheets("Rates").cells(c, 13).Text)
sStr = Application.Substitute(sStr,chr(160)," ")
sStr = Application.Clean(sStr)
If lcase(trim(Match_Code)) = sStr Then
Worksheets("Entry").Range("F8") = _
Worksheets("Rates").cells(c, 15)
exit for ' match has been made, so quit
End If
Next c
--
Regards,
Tom Ogilvy
"rdavis7408" wrote in message
om...
I have a workbook that has a worksheet in it that has transportation
carriers' rates. The rates are unique by carrier abbreviation,
equipment type, and destination zip zone. I have combined these
combining these three variables into a single field in each record
called Match_Code.
What I have is a error when I attempt to match these values against
the cell in the rows of the spreadsheet.
Match_Code = Carrier_Abbreviation & Equipment_Type & Zone
For c = 2 to 5961
If Match_Code = worksheets("Rates").cells(c, 13) Then
Worksheets("Entry").Range("F8") =
Worksheets("Rates").cells(c, 15)
End If
Next c
Everytime I run the above I get a Run-Time Error '13' Type Mismatch.
I can match Carrier_Abbreviation by itself in the loop and
Equipment_Type by itself in the loop. I am unable to match with the
Zone variable which is a alpha numeric code like 744PA.
Does anyone know why this is occurring? Any help is appreciated.
Thanks in advance.
Robert
|