Results 1 to 20 of 68

Thread: Advice needed to speed this code.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    VBAX Expert
    Joined
    May 2016
    Posts
    604
    Location
    Hi,
    apologies for my incomplete answer, but try this which uses the same technique but does a double loop

    Sub test()
    With ThisWorkbook.Sheets("Sheet1")
        lLR = Cells(Rows.Count, "A").End(xlUp).Row
    End With
    
    inarr = Range("AY59:EX" & lLR)
     'assigning the main loading formula
    Application.StatusBar = " Automated Planning : Computing ...."
    
     '    With Range("AY59:EX" & lLR)
     '        .Formula = "=IF(OR($AF59="""",$AF59="""",$AJ59=""""),0,IF(AY$58<$AJ59,0,IF(AY$58>=$AJ59,IF(0<($AN59),MIN(($AN59-'SUM(AX59:$AX59)),$AO59,SUMIF(Shadow_Dept_Lines_Sum_Col,$AM59,AY$4:AY$56)-SUMIF($AM$58:$AM58,$AM59,AY$58))))))"
     '        '.Application.Calculation = xlCalculationAutomatic
     '        .Value = .Value
     '    End With
    
    endarray = 59 - lLR
    ' column ex is column 154 column ay is column 59
    endcol = 154 - 51
    
    For i = 1 To endarray
    For j = 1 To endcol
        inarr(i, j) = "=IF(OR($AF59="""",$AF59="""",$AJ59=""""),0,IF(AY$58<$AJ59,0,IF(AY$58>=$AJ59,IF(0<($AN59),MIN(($AN59-SUM(AX59:$AX59)),$AO59,SUMIF(Shadow_Dept_Lines_Sum_Col,$AM59,AY$4:AY$56)-SUMIF($AM$58:$AM58,$AM59,AY$58))))))"
    Next j
    Next i
    
    Range("AY59:EX" & lLR) = inarr
    End Sub
    Last edited by SamT; 05-21-2016 at 08:02 AM. Reason: Added CODE Tags with Editor's # icon. Added white space

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •