Optimizing Coding Structure and Workbook Speed/Functionality

reberryjr

Well-known Member
Joined
Mar 16, 2017
Messages
701
Office Version
  1. 365
Platform
  1. Windows
I need some guidance on how to best approach a situation. I have a workbook that will have 40+ sheets. One of the sheets is mean to serve as a Summary sheet, containing data from the others. In creating this summary sheet, I enter a slew of formulas (from column F through column BV). This seems to be causing my workbook to drag. I've googled the situation and I see suggestions that I should limit the use of formulas, and use code instead. I'm struggling with how I would effectively translate these formulas (I've included a small example below) to code.

Immediate challenges include:
  • Not ever worksheet exists until it's created by a command button on a userform, hence the Indirect functions.
  • I would want the formula results to update as information on the respective sheet is changed, as well as every day, since many of these are date calculations, based off of =Today().
  • I'm still learning VBA, so I don't have extensive knowledge of its capabilities.

Code:
'ws2.Range("F" & LastRow2 + 1).FormulaArray = "=MAX(IF(INDIRECT(""'""&RC[-2]&""'!D:D"")='Client Summaries'!RC[-2],INDIRECT(""'""&RC[-2]&""'!L:L"")))"
'ws2.Range("G" & LastRow2 + 1).FormulaArray = "=MAX(IF(INDIRECT(""'""&RC[-3]&""'!D:D"")='Client Summaries'!RC[-3],INDIRECT(""'""&RC[-3]&""'!R:R"")))"
'ws2.Range("H" & LastRow2 + 1).FormulaArray = "=MAX(IF(INDIRECT(""'""&RC[-4]&""'!D:D"")='Client Summaries'!RC[-4],INDIRECT(""'""&RC[-4]&""'!AA:AA"")))"
'ws2.Range("I" & LastRow2 + 1).FormulaArray = "=MAX(IF(INDIRECT(""'""&RC[-5]&""'!D:D"")='Client Summaries'!RC[-5],INDIRECT(""'""&RC[-5]&""'!AK:AK"")))"
'ws2.Range("J" & LastRow2 + 1).FormulaArray = "=MAX(IF(INDIRECT(""'""&RC[-6]&""'!D:D"")='Client Summaries'!RC[-6],INDIRECT(""'""&RC[-6]&""'!AU:AU"")))"
'ws2.Range("K" & LastRow2 + 1).FormulaArray = "=MAX(IF(INDIRECT(""'""&RC[-7]&""'!D:D"")='Client Summaries'!RC[-7],INDIRECT(""'""&RC[-7]&""'!BE:BE"")))"
'ws2.Range("L" & LastRow2 + 1).FormulaArray = "=MAX(IF(INDIRECT(""'""&RC[-8]&""'!D:D"")='Client Summaries'!RC[-8],INDIRECT(""'""&RC[-8]&""'!BO:BO"")))"
'ws2.Range("M" & LastRow2 + 1).FormulaArray = "=MAX(IF(Stats!C[-10]='Client Summaries'!RC[-10],Stats!C[-5]))"
'ws2.Range("N" & LastRow2 + 1).FormulaArray = "=RC[-13]-RC[-1]"
'ws2.Range("O" & LastRow2 + 1).FormulaArray = "=INDEX(STATS!C[-5],MATCH(MIN(IF(STATS!C[-12]=RC[-12],STATS!C[-7])),IF(STATS!C[-12]=RC[-12],STATS!C[-7]),0))"
'ws2.Range("P" & LastRow2 + 1).FormulaArray = "=MIN(IF(STATS!C[-13]='CLIENT SUMMARIES'!RC[-13],STATS!C[-8]))"
'ws2.Range("Q" & LastRow2 + 1).Value = "=RC[-1]-RC[-2]"
'ws2.Range("R" & LastRow2 + 1).FormulaArray = "=INDEX(STATS!C[-8],MATCH(MAX(IF(STATS!C[-15]=RC[-15],STATS!C[-10])),IF(STATS!C[-15]=RC[-15],STATS!C[-10]),0))"
'ws2.Range("S" & LastRow2 + 1).Value = "=RC[-1]-RC[-4]"
'ws2.Range("T" & LastRow2 + 1).FormulaArray = "=INDEX(STATS!C[-8],MATCH(MIN(IF(STATS!C[-17]=RC[-17],STATS!C[-12])),IF(STATS!C[-17]=RC[-17],STATS!C[-12]),0))"
'ws2.Range("U" & LastRow2 + 1).FormulaArray = "=MIN(IF(STATS!C[-18]='CLIENT SUMMARIES'!RC[-18],STATS!C[-9]))"
'ws2.Range("V" & LastRow2 + 1).Value = "=RC[-1]-RC[-2]"
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,215,226
Messages
6,123,734
Members
449,116
Latest member
alexlomt

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