Load multiple data tables into arrays and using vlookup on the arrays for speed improvement

Waimea

Active Member
Joined
Jun 30, 2018
Messages
342
I have a couple of hundred rows that I want to vlookup and I have over 100 data tabels, when I change a combobox a couple of thousand formulas recalculate.

And it takes a couple of seconds to recalculate and I am looking at ways to increase speed.

Will it be faster do load every data table into an array and then using vlookup or vlookup/match on those arrays?

Are there any negative things with loading 100+ tables into arrays? Is there something I am missing?
 

Waimea

Active Member
Joined
Jun 30, 2018
Messages
342
I have a table with 10 columns and with 300 rows, how would I load the table into an array and then comparing the 9 columns in batches of 3?

I want to test if metric1 2019 is higher or lower then metric1 2018 and if metrci1 2018 is higher or lower then metric1 2017.

Ex.

Column1 has Country

Column2 has Metric1 2017
Column3 has Metric1 2018
Column4 has Metric1 2019

Column5 has Metric2 2017
Column6 has Metric2 2018
Column7 has Metric2 2019

Column8 has Metric3 2017
Column9 has Metric3 2018
Column10 has Metric3 2019

Code:
Dim myarray As Variant

myarray = Sheet4.ListObjects("Data").DataBodyRange.Value
 
Last edited:

Waimea

Active Member
Joined
Jun 30, 2018
Messages
342
It would be very kind of someone could give me a hint on where I should start with this coding problem?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
30,533
Office Version
365
Platform
Windows
Cross posted https://www.excelforum.com/excel-programming-vba-macros/1266872-how-to-use-array-declared-in-vba-in-spreadsheet.html

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 

Waimea

Active Member
Joined
Jun 30, 2018
Messages
342
I am loading two tables into arrays and given them a name with the name manager and I can VLOOKUP them.

Code:
=VLOOKUP($K$5;arrVal;4;FALSE)
However, I want to use VLOOKUP and MATCH?

Code:
Sub testarray()
'arrVal = Sheet4.ListObjects("Table2").DataBodyRange.Value
arrVal = Sheet4.ListObjects("Table2").Range.Value


Names.Add Name:="arrVal", RefersTo:=arrVal, Visible:=True
End Sub
I have tried with both DataBodyRange and Range.

How can I use VLOOKUP and MATCH on my array? Or INDEX and MATCH?

Seems like I can use HeaderRowRange.Value ?
 
Last edited:

Waimea

Active Member
Joined
Jun 30, 2018
Messages
342
I created a second array with the headerrowrange in it and used that array in the match function! :)
 

Forum statistics

Threads
1,078,447
Messages
5,340,349
Members
399,371
Latest member
wilbot

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top