Hello,
I am trying to speed up a macro by passing a range to an array, loop through and add formulas to cells (uses a sheet name that changes), then pass back to the range.... I have it working without an array but it runs very slow.... The range that has 1700 rows takes almost an hour to loop through...
Dim arrCSS() As Long
Dim arr_CSS As Variant
Dim Y_CSS As Integer
Dim Y As Long
Dim copyWs As Worksheet
Dim Testsheet As Worksheet
Dim cName As String
' Application.Calculation = xlManual
Set copyWs = Sheets("Cost Summary")
Y_CSS = copyWs.Range("B" & Rows.count).End(xlUp).Row
arr_CSS = Range("B10:BN" & Y_CSS).Value
For Y = 10 To UBound(arrCSS)
cName = copyWs.Range("B" & Y)
copyWs.Range("AF" & Y).Formula = "=IF('" & cName & "'!U5=0,"""",'" & cName & "'!U5)" 'Data Management
copyWs.Range("AG" & Y).Formula = "=IF('" & cName & "'!V5=0,"""",'" & cName & "'!V5)" 'Lead Engineer
'There are 20 more of these statements to add more formulas, took them out to save space
Next Y
Range("B10:BN" & Y_CSS).Value = arr_CSS
I believe that I am passing the range to the array, I just do not understand how to manipulate the array...
cName variable in the original code gets the cell value from the first row and uses it as a string to help make the unique formulas...
Any help on this would be great, thank you!
Steve
I am trying to speed up a macro by passing a range to an array, loop through and add formulas to cells (uses a sheet name that changes), then pass back to the range.... I have it working without an array but it runs very slow.... The range that has 1700 rows takes almost an hour to loop through...
Dim arrCSS() As Long
Dim arr_CSS As Variant
Dim Y_CSS As Integer
Dim Y As Long
Dim copyWs As Worksheet
Dim Testsheet As Worksheet
Dim cName As String
' Application.Calculation = xlManual
Set copyWs = Sheets("Cost Summary")
Y_CSS = copyWs.Range("B" & Rows.count).End(xlUp).Row
arr_CSS = Range("B10:BN" & Y_CSS).Value
For Y = 10 To UBound(arrCSS)
cName = copyWs.Range("B" & Y)
copyWs.Range("AF" & Y).Formula = "=IF('" & cName & "'!U5=0,"""",'" & cName & "'!U5)" 'Data Management
copyWs.Range("AG" & Y).Formula = "=IF('" & cName & "'!V5=0,"""",'" & cName & "'!V5)" 'Lead Engineer
'There are 20 more of these statements to add more formulas, took them out to save space
Next Y
Range("B10:BN" & Y_CSS).Value = arr_CSS
I believe that I am passing the range to the array, I just do not understand how to manipulate the array...
cName variable in the original code gets the cell value from the first row and uses it as a string to help make the unique formulas...
Any help on this would be great, thank you!
Steve