+ Reply to Thread
Results 1 to 2 of 2

Type Mismatch - Match function

  1. #1
    Forum Contributor
    Join Date
    08-20-2005
    Posts
    171

    Type Mismatch - Match function

    There is a slight problem with the asterixed section of the code (MATCH Function)
    if a value exists its all fine, but if there is an error I'm
    getting run-time error 13 - Type Mismatch
    Many Thanks

    Sub printtariq()

    On Error Resume Next

    Worksheets("Test").Select

    '1) Number the columns

    a = Cells.Find("WorkOrder").Column
    b = Cells.Find("CostC").Column
    c = Cells.Find("PaperSize").Column
    d = Cells.Find("PaperWeight").Column
    e = Cells.Find("NoBW").Column
    f = Cells.Find("NoColour").Column
    g = Cells.Find("printtype").Column
    h = Cells.Find("x").Column


    '2) Define last row and column
    lastrow = Range("A65500").End(xlUp).Row
    lastcol = Range("IV1").End(xlToLeft).Column

    '3) Strip letters from workorders and active workorders
    Cells(1, lastcol + 1) = "WoNo"
    Cells(1, lastcol + 1).Font.Bold = True
    i = Cells.Find("WoNo").Column
    For y = 2 To lastrow
    Cells(y, i) = Right(Cells(y, a), Len(Cells(y, a)) - 1)
    Next
    Cells(1, lastcol + 2) = "ActNo"
    For y = 2 To lastrow
    Cells(y, lastcol + 2) = Right(Cells(y, h), Len(Cells(y, h)) - 1)
    Next

    '***4) Match function
    iRow = Application.match(Cells(2, 10).Value, Range(Cells(2, 9), Cells(10, 9)), 0)
    On Error GoTo 0
    If iRow > 0 Then Cells(2, 11).Value = iRow

    End Sub

  2. #2
    Tom Ogilvy
    Guest

    RE: Type Mismatch - Match function

    dim irow as Variant

    iRow = Application.match(Cells(2, 10).Value, _
    Range(Cells(2, 9),Cells(10, 9)), 0)
    if iserror(iRow) then
    msgbox "Was not found"
    exit sub
    End if

    --
    Regards,
    Tom Ogilvy


    "T De Villiers" wrote:

    >
    > There is a slight problem with the asterixed section of the code (MATCH
    > Function)
    > if a value exists its all fine, but if there is an error I'm
    > getting run-time error 13 - Type Mismatch
    > Many Thanks
    >
    > Sub printtariq()
    >
    > On Error Resume Next
    >
    > Worksheets("Test").Select
    >
    > '1) Number the columns
    >
    > a = Cells.Find("WorkOrder").Column
    > b = Cells.Find("CostC").Column
    > c = Cells.Find("PaperSize").Column
    > d = Cells.Find("PaperWeight").Column
    > e = Cells.Find("NoBW").Column
    > f = Cells.Find("NoColour").Column
    > g = Cells.Find("printtype").Column
    > h = Cells.Find("x").Column
    >
    >
    > '2) Define last row and column
    > lastrow = Range("A65500").End(xlUp).Row
    > lastcol = Range("IV1").End(xlToLeft).Column
    >
    > '3) Strip letters from workorders and active workorders
    > Cells(1, lastcol + 1) = "WoNo"
    > Cells(1, lastcol + 1).Font.Bold = True
    > i = Cells.Find("WoNo").Column
    > For y = 2 To lastrow
    > Cells(y, i) = Right(Cells(y, a), Len(Cells(y, a)) - 1)
    > Next
    > Cells(1, lastcol + 2) = "ActNo"
    > For y = 2 To lastrow
    > Cells(y, lastcol + 2) = Right(Cells(y, h), Len(Cells(y, h)) - 1)
    > Next
    >
    > '***4) Match function
    > iRow = Application.match(Cells(2, 10).Value, Range(Cells(2, 9),
    > Cells(10, 9)), 0)
    > On Error GoTo 0
    > If iRow > 0 Then Cells(2, 11).Value = iRow
    >
    > End Sub
    >
    >
    > --
    > T De Villiers
    > ------------------------------------------------------------------------
    > T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
    > View this thread: http://www.excelforum.com/showthread...hreadid=566620
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1