You are on page 1of 29

VLOOKUP VS

XLOOKUP VS
INDEX MATCH
THE
SHOWDOWN

WITH CHATGPT
RICHARD NERO
WHO IS THE BEST?

XL
OO
P
KU

KU
OO

INDEX

P
MATCH
VL

RICHARD NERO
I asked the community
what they thought

622 of you took part in my poll


44% of you said XLOOKUP was your fav lookup function
My beloved INDEX/MATCH came last

RICHARD NERO
But I wanted to know which of the
3 is the most efficient?

Which is the fastest to calculate ?

RICHARD NERO
THE CHALLENGE

Create 1 million VLOOKUPs

Create 1 million XLOOKUPs

Create 1 million INDEX MATCHs

And chart their


calculation times

RICHARD NERO
THIS IS A BIG TASK

So lets break it down

RICHARD NERO
THE PLAN

DOWNLOAD A DATA SET


WRITE THE FORMULAS
WRITE SOME VBA
CHART RESULTS

RICHARD NERO
GET A DATASET

I went over to Kaggle

..and found this


computer game data
set from Steam

RICHARD NERO
WRITE THE 3M FORMULAS

15mins later I'm done


RICHARD NERO
RECORD
WRITE SOME VBA
I'm lazy so I hit 'Record Macro'

I clicked fill down on


1,000,000 formulas

10 columns
100k rows
WRITE SOME VBA
Few changes to my
recorded code
I use VBA code names to reference the sheets

3 macros
1 for each formula calc
RICHARD NERO
WRITE SOME VBA

We need to time the calcs but


also fire 3 different macros

1 to refresh 1m VLOOKUPs

1 to refresh 1mXLOOKUPs

1 to refresh 1mINDEX/MATCHs

RICHARD NERO
PROMPT
WRITE SOME VBA

Lets just ask ChatGPT

RICHARD NERO
THE PROMPT

RICHARD NERO

I want to test the calculation time of


different formulas.

1m VLOOKUPs vs
1m INDEX/MATCH vs
1m XLOOKUPS

What do you recommend I do?

This was a lazy prompt


so will need refining

RICHARD NERO
THE RESPONSE

CHATGPT

Here is a general approach you could use:

Creating Datasets: Create three datasets with


identical data structures

Implementing Formulas: Put the formulas into the


data sets

Setting Up A Timer: Excel doesn't have a built-in


mechanism to precisely track formula calculation
times.

But you can use VBA to create a timer.

Here's an example of how you could do this

RICHARD NERO
THE RESPONSE

CHATGPT

You would replace the 'Your 1m VLOOKUPs here'


comment with your code to do the VLOOKUPs.

1. Running the Timer and Calculations: Run the VBA


script, which will execute the VLOOKUPs and then
record the time then run again for INDEX/MATCH
code, XLOOKUP.
RICHARD NERO
THAT WAS COOL BUT...
I dont want to write down
each time

I want to fire each script 1 by 1


F11

and write the results to cells

RICHARD NERO
THE PROMPT

RICHARD NERO

That timer macro you gave me is great


but I need to call 3 different macros
and time each one. Any ideas?

This was lazy prompting


yet again #longday

RICHARD NERO
THE RESPONSE

CHATGPT

You can modify the timer macro to call three different


macros and measure the time it takes for each to run.
Here's an example:

Please note, the MsgBox pop-ups might be


inconvenient if you plan to run this code multiple
times. Consider logging the timings to a dedicated
worksheet or text file for easier review.

I don't want that msgbox


THE PROMPT

RICHARD NERO

Instead of showing a message box


write them to a sheet named 'Results'.
Any ideas?

I should really define the


exact range but yeah..
I was lazy again

RICHARD NERO
THE RESPONSE

CHATGPT

Sure, you can easily modify the VBA code to write the
results to a sheet named "Results" instead of
displaying message boxes. Here's an example of how
to do that:

Now we cooking
Macro1's time is written into
row 2,
column 2
(B2)

If I run this again


and again..

..the times will be


overwritten

We need to make it dynamic so Im


going to roll up my sleeves and
code this myself
RICHARD
LEZGOOO!!!

F11
Alt

Alt F11

RICHARD NERO
We create a variable
called lrow to find
the last row using
.End(xlDown).Row
and then add 1

to get the next


available row.

F11 We then use


lrow to find
the next 2
blank cells
lrow + 1
RICHARD NERO
lrow + 2
Time to launch the code

But one result isn't enough


so lets loop it 30 times

RICHARD NERO
WHOSE YOUR MONEY ON?

Will it be a VLOOKUP victory?

Will XLOOKUP be ecstatic?

Will INDEX/MATCH win the match?


CHART THE RESULTS
THE VERDICT

UP
OK
VLO

XLOOK
UP
INDEX
MATCH
If you enjoyed that please repost so
your network can enjoy it too

Follow for more Excel + ChatGPT tips

Richard Nero
Finance Systems Consultant |
Excel Trainer | Mentor | SQL |
Python | Power Platform Pro

Let me know what lookup


you prefer and what you
think of the results in the
comments?

You might also like