PDA

View Full Version : [SOLVED:] VBA VLOOKUP BETWEEN TWO NAMED TABLES



JILBO
08-19-2021, 10:42 AM
Hi,
I have a workbook with two tables. The first SNAG table is populated by the user during the day/week and at some point during the week he runs a power query which creates another table called export. What I'm after is when the dynamic 'export' table is created is to annotate the first SNAG table[EXPORT] column with any matching [Snag Number] columns with 'YES'.

Thankss in advance

arnelgp
08-19-2021, 05:39 PM
you already have the idea about vlookup() or countif()
https://www.dropbox.com/s/9pw65xlz09jtfxb/VBA_VlookupTables.xlsx?dl=0

JILBO
08-19-2021, 11:16 PM
Hi, yes it’s got to be VBA the EXPORT table
is dynamic and is created from
the SNAG table….it will only appear on the export table once

JILBO
08-20-2021, 01:28 AM
Got this to work however i'd like to reference the ListObject (Tables) rather than columns??? Any ideas




Sub match_columns()Dim I, total, fRow As Integer
Dim found As Range


total = Sheets("SNAGS").Range("C" & Rows.Count).End(xlUp).Row


For I = 1 To total
answer1 = Worksheets("SNAGS").Range("C" & I).Value
Set found = Sheets("DRACAS").Columns("C:C").Find(what:=answer1) 'finds a match
If found Is Nothing Then


Else
Worksheets("SNAGS").Range("F" & I).Value = Date + Time




End If
Next I




End Sub

JILBO
08-20-2021, 07:02 AM
I figured it out in the end utilsing ListObjects etc and it works a treat.