Application Match with Multiple criteria

  • Hello all,
    I use below code to select header by name "XYZ".
    Few times it gets changed to "XYZA".
    I need "Application.Match" code to select either of these header whichever is available, Like Application.Match("XYZ" or "XYZA").


    How best i can modify it..?


    Code
    Cells(1, Application.Match("ABC", Range("1:1"), 0)).Select
  • Re: Application Match with Multiple criteria


    Maybe something like this will work:


    Code
    Sub Test()
    
    
    On Error Resume Next 'Suppress Errors
    Cells(1, Application.WorksheetFunction.Match("XYZ", Range("1:1"), 0)).Select
    Cells(1, Application.WorksheetFunction.Match("XYZA", Range("1:1"), 0)).Select
    On Error GoTo 0 'Reset Error Handling
    
    
    End Sub

    Matt Mickle
    Using Excel 2010,2013 & 2016

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!