Can't get vlookup or index/match to work in compare

KDS14589

Board Regular
Joined
Jan 10, 2019
Messages
202
Office Version
  1. 2016
Platform
  1. Windows
I'm trying to compare in VBA two tables that are on the same sheet. The first table called "tableQ" and is in column "Q" (only one column wide) and starts in row 5 but ends in row 200. With no duplicates but many empty cells. Values are entered by way of a comboboxT userform that removes that value that is selected for the chosen cell in column "Q”, so that there are no duplicated values.

The other table is called "MasterT" and is in column "T" and starts in row 5 but ends at row 30. Values are entered and are use as a list for that comboboxT.

I'm comparing TableQ to the MasterT to see if a value in the MasterT has been used somewhere in the TableQ.

I've tried both vlookup and index/match but at this point I'm doing the old 'one step forward and two steps back'. HELP

My last attempt was (and of course it didn't work)(I would list all but there isn't space)

VBA Code:
With ShGE03 'ShGE03 is the worksheet codename

Dim tableQ as range

Set tableQ = .Range("Q5:Q200")

Dim MasterT as Range

Set MasterT = .Range("T5:T30")

.Range("U5:U30").Formula = "=IFERROR(VLOOKUP(T5,tableQ,2,FALSE),""Not Used"")"

End With
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Can you pls try in the last line

.Range("U5:U30").Formula = "=IFERROR(VLOOKUP(T5," & tableQ.Address & ",2,FALSE),""Not Used"")"
 
Upvote 0
It works with: "=IFERROR(VLOOKUP(T5," & tableQ.Address & ",2,FALSE),""Not Used"")" ?
 
Upvote 0
Since tableQ is a single-column range then the column index should be 1 and not 2?
 
Upvote 0
I solved this myself by modifying my code as such.................
VBA Code:
with ShGE03
Dim k As Integer
For k = 5 To 30

.Cells(k, "U").Value = "=IF(ISERROR(MATCH(R[-2]C[-1], R5C17:R110C17, 0)), ""Not Used"", """" )"

Next k
END WITH
Now I have 2 other problems that I'll post in new threads
Thanks to everyone for the suggestions
 
Upvote 0
Solution

Forum statistics

Threads
1,223,881
Messages
6,175,161
Members
452,615
Latest member
bogeys2birdies

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