Looping an XLOOKUP routine …

adambc

Active Member
Joined
Jan 13, 2020
Messages
412
Office Version
  1. 365
Platform
  1. Windows
I have two lists that I need to match using email addresses (which to date has been the only reliable key, but please keep reading!) …

The first list is a list of Users (over 1000 rows) who need to complete some training – it has several columns but the two I’m focussed on are one that comprises the User’s “MainEmailAddress” and another that contains the User’s “AllEmailAddresses” in the format …

SMTP:emailname1@domain1+SMTP:emailname2@domain1+SMTP:emailname3@domain2+SMTP:emailname4@domain2 etc etc

… where the emailname can be in various formats eg firstname.surname, firstnamesurname, initialsurname, initial.surname and a few others thrown in for good measure and there are a number of domains – BUT … every User is different ie they may only have a single email address, or they may have n email addresses, which may span all emailname & domain options, or may not!

As a start I have used Text to Column, then removed the SMTP: preface to get “clean” email addresses in separate columns

The second list is a list of Users who have completed the training with the date completed – again it has several columns but the two I’m focussed on are “EmailAddress” and “DateCompleted” – and you’ve got it, I want to know which Users on the first list also appear on the second list (to get a % complete) – and which Users don’t appear (so we can chase them!) …

To date it’s been easy because the organisation I’m doing this voluntary work for have enforced the use of firstname.surname@theirprimarydomain for ALL systems, but following a recent merger with another charitable organisations, the second list might (and does!) use one of the other email addresses (not always the same format!) and I need a way to extend the XLOOKUP routine I’m using (as part of a macro that also opens the source lists, does some filtering/sorting, saves as an output file, etc, etc) to loop through every Users email addresses until a match is found, or return a null value …

But I can’t see the wood for the trees and I need some help please!

Any takers?

Many thanks

PS; I can’t share my files because they contain personal data – but I could create a short mock up if my explanation above doesn’t make sense …
 
You cannot use structured references on a closed workbook. You will need to convert them to normal ranges.
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Use format as table, and then use table references in your formulas.
MrExcelPlayground16.xlsx
ABCDE
1emailstrained?Date?List of trainedDate completed
2SMTP:jcanale@goose.com+SMTP:JamesC@goose.com+SMTP:Thor@hotmail.comTRUE1/1/2021jamesc@goose.com1/1/2021
3SMTP:fred@goose.comTRUE1/2/2023fred@goose.com1/2/2023
4SMTP:Sally@goose.com+SMTP:Sjones@goose.comFALSENot Trainedpatriot@mcu.com6/1/2023
5SMTP:Warmachinerocks@mcu.com+SMTP:Patriot@MCU.comTRUE6/1/2023
6SMTP:abc@def.com+SMTP:abc@otherthing.comFALSENot Trained
Sheet9
Cell Formulas
RangeFormula
B2:B6B2=OR(ISNUMBER(SEARCH(":"&Table2[List of trained],A2)))
C2:C6C2=IF(OR(ISNUMBER(SEARCH(":"&Table2[List of trained],A2))),SUMPRODUCT(IFERROR(SIGN(SEARCH(":"&Table2[List of trained],A2)),0),Table2[Date completed]),"Not Trained")
@JamesCanale

Me again!

Is there a way to write these formulas as VBA WorksheetFunction routines?

Just looking for some performance improvement over having Excel formulas in every cell?

Thanks …
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

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