Hi,
I am currently working on the below a macro that loops through a range and inserts a formula depending on the value of a cell outside of the range. I am running about 5 of these in the same macro and the work fine, but the time to execute is quite long (1.5min). I am looking to run this frequently throughout the day and I was wondering if there are any suggestions on how I can speed it up?
I appreciate any ideas you might have.
Many thanks,
OVikstrom
I am currently working on the below a macro that loops through a range and inserts a formula depending on the value of a cell outside of the range. I am running about 5 of these in the same macro and the work fine, but the time to execute is quite long (1.5min). I am looking to run this frequently throughout the day and I was wondering if there are any suggestions on how I can speed it up?
Code:
Sub improvedmacro()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual
For Each c In Worksheets("Fund Data").Range("J4:J195").Cells
If c.Offset(0, -6).Value = "Lux" Then
c.FormulaArray = "=INDEX('Lux Data'!C[-9]:C[-1],MATCH(1,('Lux Data'!C[-9]=RC[-5])*('Lux Data'!C[-7]=RC[-4])*('Lux Data'!C[-2]=""NET SHARES OUTSTANDING""),0),9)"
ElseIf c.Offset(0, -6).Value = "Ire" Then
c.FormulaArray = "=INDEX('Irish Data'!C[-9]:C[-1],MATCH(1,('Irish Data'!C[-9]=RC[-5])*('Irish Data'!C[-7]=RC[-4])*('Irish Data'!C[-2]=""NET SHARES OUTSTANDING""),0),9)"
ElseIf c.Offset(0, -6).Value = "CH" Then
c.FormulaR1C1 = "=VLOOKUP(RC3,'Swiss NAV'!R1C2:R23C21,12,FALSE)"
End If
Next
End Sub
I appreciate any ideas you might have.
Many thanks,
OVikstrom