VBA Formula Takes too long

Daniellel

Board Regular
Joined
Jun 21, 2011
Messages
242
Hi,

I have written some VBA code to insert a formula into approx 450+ cells. The formula is...

Selection.FormulaArray = _
"=INDEX(TO3!$C$1:$I$9999,MATCH($A9&$B9,TO3!$A$1:$A$9999&TO3!$B$1:$B$9999,0),COLUMNS(TO3!$C2:C2))"

This has now added about 30 mins onto my VBA update and the list is only going to get bigger, is there anything i can do to speed this up???
 
Oops good spot Jon

Should be

Sub autoUpdate()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False

'Do your code then switch back on

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.DisplayAlerts = True


End Sub
 
Upvote 0

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
It is probably a lot faster if you add helper columns which combine the two strings you are searching for and then use a non-array formula to do the INDEX/MATCH.

If the list you are looking up can be sorted on the lookup column, it may be even faster to do a non-exact match.

Suppose you want to match a value in Column A of sheet1 and return the associated value in column B. Column A is sorted.
Normally you would do either:

=VLOOKUP(Sheet1!$A$1:$B$1000,2,False)

or
=INDEX(Sheet1!$B$1:$B$1000,MATCH(A1,Sheet1!$A$1:$A$1000,0))

Both doing an exact match search.

This approach however is as much as 3 to 5 times faster:

=IF(INDEX(Sheet1!$A$1:$A$1000,MATCH(A1,Sheet1!$A$1:$A$1000,1))=A1,INDEX(Sheet1!$B$1:$B$1000,MATCH(A1,Sheet1!$A$1:$A$1000,1)),NA())
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,717
Members
452,939
Latest member
WCrawford

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