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???
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Have you switched off auto update and also calculations to speed this up.

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> autoUpdate()<br>Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br>Application.Calculate = xlCalculationManual<br>Application.DisplayAlerts = <SPAN style="color:#00007F">False</SPAN><br><br><SPAN style="color:#007F00">'Do your code then switch back on</SPAN><br><br>Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br>Application.Calculate = xlCalculationAutomatic<br>Application.DisplayAlerts = <SPAN style="color:#00007F">True</SPAN><br><br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0
I'm assuming the area that this formula occupies spans multiple columns?

Why not split the MATCH into a helper column. That way you use a single helper column to yield the row index. Your INDEX formula can then refer to the helper column.
 
Upvote 0
Have you switched off auto update and also calculations to speed this up.


Thank you for this but i am an absolute begginer on VBA and am trying to self teach, can you show exactly how this should look? I tried it and it didnt like it???
 
Upvote 0
I'm assuming the area that this formula occupies spans multiple columns?

Why not split the MATCH into a helper column. That way you use a single helper column to yield the row index. Your INDEX formula can then refer to the helper column.


Again, Thank you for this but i am an absolute begginer on VBA and am trying to self teach, can you show exactly how this should look?
 
Upvote 0
Thank you for this but i am an absolute begginer on VBA and am trying to self teach, can you show exactly how this should look? I tried it and it didnt like it???

You state you have a macro and I assume you have written that macro.

At the beginning of the Sub routine is where you place the application commands, exactly as I showed in my reply.

In the green text area is where you place in your code, as stated, then at the end of the code you add in the other part to place the commands back on.
 
Upvote 0
You state you have a macro and I assume you have written that macro.

At the beginning of the Sub routine is where you place the application commands, exactly as I showed in my reply.

In the green text area is where you place in your code, as stated, then at the end of the code you add in the other part to place the commands back on.

Thanks again,

This is showing an error message:

Compile Error : Expected Function or variable
 
Upvote 0
It should be calculation

Also I don't think you should include the DisplayAlerts bit because it may block potentially important alerts.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,704
Members
452,938
Latest member
babeneker

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