Excel/array formulas in VBA
I have the following array formula in a worksheet:
It is copied through rows BA12:BA60. The worksheet is duplicated several times across the whole workbook. I am concerned that this is increasing the time that it takes to save the workbook.
The formula is located in worksheet: “SPtemplate2”. Can an array formula be written in VBA? If so could you possibly do this for me and tell me where to place it?
Thanks in advance
If wanted to run a macro that puts in that formula and then replaces it with the results you would need to know where to put it. Lets say you want to put the formula in Range A1:A100 of the activeworksheet
Dim cell as Range
Dim i as long
i = 0
for each cell in Range("A1:A100")
i = i + 1
cell.formulaArray = "=IF($BA$10="""","""",IFERROR(INDEX(name," & _
"SMALL(IF(LEFT(Group2,LEN(SPtemplate2!$BA$10))=SPtemplate2!$BA$10," & _
"ROW(Group2)),ROW(A" & i & ")),1),""""))"
cell.formula = cell.value
So you would run this macro whenever you wanted cells A1:A100 updated.
Always test new code on a copy of your owrkbook until you are satisfied it behaves as expected.
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here