Rick,
Your code (in red) as it integrates with a snipet of my code. I am so greatful for this intricate and well devised code and the example it sets for the use of Evaluate, Intersect and xlWhole. I appreciate the opportunity to learn so much on a web site that has so many talented contributors.
SteveCode:Sub Freeze() Dim Tt As Long Dim Rb As Integer Dim FirstRow As Long, LastRow As Long Dim AddrA As String, AddrB As String Dim RngA As Range, RngB As Range, RowRng As Range Application.ScreenUpdating = False On Error Resume Next Sheets("INVESTOR INTERFACE").Activate Application.Calculation = xlCalculationManual With Sheets("INVESTOR INTERFACE") 'FREEZE/STORE TICK-CITY DATABASE Let Tt = Application.Range("WHERE15").Value Let Rb = Application.Range("reachBACK").offset(0, -1).Value If Rb > Tt - 3 Then Rb = Tt - 4 If Rb = 0 Then Exit Sub End If Set RngA = Sheets("INVESTOR INTERFACE").Range(.Cells(Tt, 128).offset(-Rb, 0), .Cells(Tt, 130)) Set RngB = RngA.offset(0, 13) FirstRow = RngB(1).Row LastRow = RngA(1).offset(RngA.Rows.Count).Row - 1 AddrA = Intersect(Rows(FirstRow & ":" & LastRow), Columns("DX:DZ")).Address AddrB = Intersect(Rows(FirstRow & ":" & LastRow), Columns("EK:EM")).Address Range(AddrB) = Evaluate("IF(" & AddrB & "=""""," & AddrA & ",IF(" & AddrA & _ "=""""," & AddrB & ",(" & AddrB & "+" & AddrA & ")/2))") Range(AddrB).Replace 0, "", xlWhole ' Erase formulas on this passing train so cells don't have to be calculated [35,000 rows] If Tt > 12 Then RngA.offset(-11, 0).Resize(24, 3).ClearContents End With On Error GoTo 0 Application.Calculation = xlCalculationAutomatic End Sub




Reply With Quote
Bookmarks