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 …
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Something like this? I added the ":"& in so that it would distinguish between ASMITH@goose.com and JASMITH@goose.com

MrExcelPlayground16.xlsx
ABCD
1emailstrained?List of trained
2SMTP:jcanale@goose.com+SMTP:JamesC@goose.com+SMTP:Thor@hotmail.comTRUEjamesc@goose.com
3SMTP:fred@goose.comTRUEfred@goose.com
4SMTP:Sally@goose.com+SMTP:Sjones@goose.comFALSEpatriot@mcu.com
5SMTP:Warmachinerocks@mcu.com+SMTP:Patriot@MCU.comTRUE
6SMTP:abc@def.com+SMTP:abc@otherthing.comFALSE
Sheet9
Cell Formulas
RangeFormula
B2:B6B2=OR(ISNUMBER(SEARCH(":"&$D$2:$D$4,A2)))
 
Upvote 0
Something like this? I added the ":"& in so that it would distinguish between ASMITH@goose.com and JASMITH@goose.com

MrExcelPlayground16.xlsx
ABCD
1emailstrained?List of trained
2SMTP:jcanale@goose.com+SMTP:JamesC@goose.com+SMTP:Thor@hotmail.comTRUEjamesc@goose.com
3SMTP:fred@goose.comTRUEfred@goose.com
4SMTP:Sally@goose.com+SMTP:Sjones@goose.comFALSEpatriot@mcu.com
5SMTP:Warmachinerocks@mcu.com+SMTP:Patriot@MCU.comTRUE
6SMTP:abc@def.com+SMTP:abc@otherthing.comFALSE
Sheet9
Cell Formulas
RangeFormula
B2:B6B2=OR(ISNUMBER(SEARCH(":"&$D$2:$D$4,A2)))
@JamesCanale

Very close - thanks …

Need to think through how …

If DateCompleted was in column E (the second list - columns D and E - is in a separate file that is an extract from an elearning system which is refreshed twice weekly) how could I go about populating column C with the date for those records = TRUE in column B?

Thanks again …
 
Upvote 0
If they will only appear once in column D - you won't need column B anymore.

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(":"&$D$2:$D$4,A2)))
C2:C6C2=IF(OR(ISNUMBER(SEARCH(":"&$D$2:$D$4,A2))),SUMPRODUCT(IFERROR(SIGN(SEARCH(":"&$D$2:$D$4,A2)),0),$E$2:$E$4),"Not Trained")
 
Upvote 0
Solution
If they will only appear once in column D - you won't need column B anymore.

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(":"&$D$2:$D$4,A2)))
C2:C6C2=IF(OR(ISNUMBER(SEARCH(":"&$D$2:$D$4,A2))),SUMPRODUCT(IFERROR(SIGN(SEARCH(":"&$D$2:$D$4,A2)),0),$E$2:$E$4),"Not Trained")
@JamesCanale

I was working through using IF, but was way off getting there!

This is exactly what I need - THANK YOU
 
Upvote 0
If this ever gives a year in the 2140s, it means that the person was trained twice.
 
Upvote 0
If they will only appear once in column D - you won't need column B anymore.

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(":"&$D$2:$D$4,A2)))
C2:C6C2=IF(OR(ISNUMBER(SEARCH(":"&$D$2:$D$4,A2))),SUMPRODUCT(IFERROR(SIGN(SEARCH(":"&$D$2:$D$4,A2)),0),$E$2:$E$4),"Not Trained")
@JamesCanale

Quick question if I may?

My column D is different in the number of rows every week - can you think of a way to ignore blanks (they force TRUE in column B?

Thanks
 
Upvote 0
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")
 
Upvote 0
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

All working perfectly thanks to you …

Except links don’t work if other WB is closed (and previous values lost if target file opened in isolation!) …

Any ideas?

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