Match issue

rollingzep

Board Regular
Joined
Nov 18, 2013
Messages
214
Office Version
  1. 365
Platform
  1. Windows
Hi,

I do a Match between two workbooks. It works fine.
The field in first WB looks at Col A or Col B and returns values from col C of the second WB.
I now need a third condition. If there are no matches, then it should be "NA".
How to do this?


VBA Code:
       Data = .Value
        With wbexcelEXT.Sheets("HQ").Cells(1).CurrentRegion
            For i = 2 To UBound(Data)
                Chk = Application.Match(Data(i, 33), .Columns(1), 0)
                If IsError(Chk) Then
                    Chk = Application.Match("*" & Data(i, 33) & "*", .Columns(2), 0)
                End If
                If Not IsError(Chk) Then Data(i, 55) = .Cells(Chk, 3)
            Next i
        End With
        .Value = Data
    End With
    ws.Range("BC:BC").NumberFormat = "@"
 
Sorry I had missing equal marks:
VBA Code:
  Dim Chk1 As Range, Chk2 As Range

  With wbexcel.Sheets("TSS Fails").Cells(1).CurrentRegion.Resize(, 45)
    Data = .Value
        With wbexcelEXT.Sheets("HQLA").Cells(1).CurrentRegion
        For i = 2 To UBound(Data)
         Set Chk1 = .Columns(1).Find(what:=Data(i, 33), LookIn:=xlFormulas, lookat:=xlWhole)
         Set Chk2 = .Columns(2).Find(what:=Data(i, 33), LookIn:=xlFormulas, lookat:=xlWhole)
         If Not Chk1 Is Nothing Then
           Data(i, 55) = .Cells(Application.Match(Data(i, 33), .Columns(1), 0), 3)
         ElseIf Not Chk2 Is Nothing Then
           Data(i, 55) = .Cells(Application.Match(Data(i, 33), .Columns(2), 0), 3)
         Else
           Data(i, 55) = "NA"
         End If
        Next i
        End With
        .Value = Data
    End With
Thanks. That worked!
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,215,514
Messages
6,125,267
Members
449,219
Latest member
daynle

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