Improve VBA Code to Run Faster

bmkelly

Board Regular
Joined
Mar 26, 2020
Messages
172
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a pretty lengthy code that takes about 4-5 minutes to run and was wondering if there is any improvements that could be made to it to help cut the run time down some?

VBA Code:
Sub AscCSFormat()

Application.Calculation = xlManual
Application.ScreenUpdating = False
Application.EnableEvents = False

'Select the correct worksheet and table then remove filters'
    Worksheets(15).Activate
    
    On Error Resume Next
        ActiveSheet.ShowAllData
    On Error GoTo 0
        With Cells
            .EntireColumn.Hidden = False
            .EntireRow.Hidden = False
        End With

'Adjust column widths'
    Columns("E:E").ColumnWidth = 80
    Columns("F:F").ColumnWidth = 37
    Columns("G:G").EntireColumn.AutoFit
    Columns("H:H").EntireColumn.AutoFit
    Columns("I:I").ColumnWidth = 60
    Columns("J:J").ColumnWidth = 60
    Columns("K:K").ColumnWidth = 108

    ActiveWorkbook.Worksheets(15).ListObjects(1).Sort.SortFields.Clear
    ActiveWorkbook.Worksheets(15).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(15).ListObjects(1).Name & "[QuarterSerial]"), SortOn:=xlSortOnValues, Order:= _
        xlAscending, DataOption:=xlSortNormal
    ActiveWorkbook.Worksheets(15).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(15).ListObjects(1).Name & "[Transaction Code]"), SortOn:=xlSortOnValues, Order:= _
        xlAscending, DataOption:=xlSortNormal
    ActiveWorkbook.Worksheets(15).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(15).ListObjects(1).Name & "[Absolute Value]"), SortOn:=xlSortOnValues, Order:= _
        xlDescending, DataOption:=xlSortNormal
    ActiveWorkbook.Worksheets(15).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(15).ListObjects(1).Name & "[Description]"), SortOn:=xlSortOnValues, Order:= _
        xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets(15).ListObjects(1).Sort
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With

Dim oLo As ListObject, l As Long, note As String
    Set oLo = Worksheets(15).ListObjects(1)
        With oLo
    For l = 1 To .ListRows.Count

note = "Retired - No Coverage"
        If .ListColumns("Transaction Type").DataBodyRange(l, 1).Value = "Retirement" Then
            .ListColumns("TriMedx Coverage").DataBodyRange(l, 1).Value = note
        End If

note = "All Parts & Labor"
        If .ListColumns("TriMedx Coverage").DataBodyRange(l, 1).Value = "Missing Coverage" Then
            .ListColumns("TriMedx Coverage").DataBodyRange(l, 1).Value = note
        End If
        
        Next l

        End With
        
'Change Header to Proration Date'
    Rows("1:1").Replace What:="*Proration Date*", Replacement:="Proration Date", LookAt _
        :=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
        
Dim LastColumn As Long

    LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column
        For i = 1 To LastColumn
    If UCase(Cells(1, i)) = "CEID" Or UCase(Cells(1, i)) = "SERIAL" Or UCase(Cells(1, i)) = "RETIRED DATE" Or UCase(Cells(1, i)) = "PRORATION DATE" Then Columns(i).Hidden = True
        Next
        
ActiveSheet.ResetAllPageBreaks

Dim hdr As Range, f As Range, r As Range
Dim cell As String
  
    Set hdr = Rows(1).Find("Transaction Date", , xlValues, xlWhole, , , False)
        If Not hdr Is Nothing Then
    Set r = Columns(hdr.Column)
    Set f = r.Find("*Total*", , xlValues, xlPart, , , False)
        If Not f Is Nothing Then
            cell = f.Address
        Do
            f.Offset(1).PageBreak = xlPageBreakManual
        Set f = r.FindNext(f)
        
      Loop While Not f Is Nothing And f.Address <> cell
      
    End If
    
  End If
     
Dim ws As Worksheet

Set ws15 = Worksheets(15)
Set oLo = ws15.ListObjects(1)

With oLo
    For i = 1 To .ListRows.Count
        If .ListColumns("Annual Service Price").DataBodyRange.Cells(i, 1).Value = 0 Then
            If InStr(.ListColumns("Transaction Date").DataBodyRange.Cells(i, 1).Value, "Total") = 0 Then
                ws15.Rows(oLo.HeaderRowRange.Row + i).Hidden = True
            End If
        End If
    Next i
End With
        
'Select the correct worksheet and table then remove filters'
    Worksheets(16).Activate
    
    On Error Resume Next
        ActiveSheet.ShowAllData
    On Error GoTo 0
        With Cells
            .EntireColumn.Hidden = False
            .EntireRow.Hidden = False
        End With
        
'Adjust column widths'
    Columns("E:E").ColumnWidth = 80
    Columns("F:F").ColumnWidth = 37
    Columns("G:G").EntireColumn.AutoFit
    Columns("H:H").EntireColumn.AutoFit
    Columns("I:I").ColumnWidth = 60
    Columns("J:J").ColumnWidth = 60
    Columns("K:K").ColumnWidth = 108
    
    ActiveWorkbook.Worksheets(16).ListObjects(1).Sort.SortFields.Clear
    ActiveWorkbook.Worksheets(16).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(16).ListObjects(1).Name & "[QuarterSerial]"), SortOn:=xlSortOnValues, Order:= _
        xlAscending, DataOption:=xlSortNormal
    ActiveWorkbook.Worksheets(16).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(16).ListObjects(1).Name & "[Transaction Code]"), SortOn:=xlSortOnValues, Order:= _
        xlAscending, DataOption:=xlSortNormal
    ActiveWorkbook.Worksheets(16).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(16).ListObjects(1).Name & "[Absolute Value]"), SortOn:=xlSortOnValues, Order:= _
        xlDescending, DataOption:=xlSortNormal
    ActiveWorkbook.Worksheets(16).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(16).ListObjects(1).Name & "[Description]"), SortOn:=xlSortOnValues, Order:= _
        xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets(16).ListObjects(1).Sort
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With

    Set oLo = Worksheets(16).ListObjects(1)
        With oLo
    For l = 1 To .ListRows.Count

note = "Retired - No Coverage"
        If .ListColumns("Transaction Type").DataBodyRange(l, 1).Value = "Retirement" Then
            .ListColumns("TriMedx Coverage").DataBodyRange(l, 1).Value = note
        End If

note = "All Parts & Labor"
        If .ListColumns("TriMedx Coverage").DataBodyRange(l, 1).Value = "Missing Coverage" Then
            .ListColumns("TriMedx Coverage").DataBodyRange(l, 1).Value = note
        End If
        
        Next l

        End With
        
'Change Header to Proration Date'
    Rows("1:1").Replace What:="*Proration Date*", Replacement:="Proration Date", LookAt _
        :=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
        
    LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column
        For i = 1 To LastColumn
    If UCase(Cells(1, i)) = "CEID" Or UCase(Cells(1, i)) = "SERIAL" Or UCase(Cells(1, i)) = "RETIRED DATE" Or UCase(Cells(1, i)) = "PRORATION DATE" Then Columns(i).Hidden = True
        Next
        
ActiveSheet.ResetAllPageBreaks
 
    Set hdr = Rows(1).Find("Transaction Date", , xlValues, xlWhole, , , False)
        If Not hdr Is Nothing Then
    Set r = Columns(hdr.Column)
    Set f = r.Find("*Total*", , xlValues, xlPart, , , False)
        If Not f Is Nothing Then
            cell = f.Address
        Do
            f.Offset(1).PageBreak = xlPageBreakManual
        Set f = r.FindNext(f)
        
      Loop While Not f Is Nothing And f.Address <> cell
      
    End If
    
  End If
     
Dim ws16 As Worksheet

Set ws16 = Worksheets(16)
Set oLo = ws16.ListObjects(1)

With oLo
    For i = 1 To .ListRows.Count
        If .ListColumns("Annual Service Price").DataBodyRange.Cells(i, 1).Value = 0 Then
            If InStr(.ListColumns("Transaction Date").DataBodyRange.Cells(i, 1).Value, "Total") = 0 Then
                ws16.Rows(oLo.HeaderRowRange.Row + i).Hidden = True
            End If
        End If
    Next i
End With
        
'Select the correct worksheet and table then remove filters'
    Worksheets(17).Activate
    
    On Error Resume Next
        ActiveSheet.ShowAllData
    On Error GoTo 0
        With Cells
            .EntireColumn.Hidden = False
            .EntireRow.Hidden = False
        End With
        
'Adjust column widths'
    Columns("E:E").ColumnWidth = 80
    Columns("F:F").ColumnWidth = 37
    Columns("G:G").EntireColumn.AutoFit
    Columns("H:H").EntireColumn.AutoFit
    Columns("I:I").ColumnWidth = 60
    Columns("J:J").ColumnWidth = 60
    Columns("K:K").ColumnWidth = 108
    
    ActiveWorkbook.Worksheets(17).ListObjects(1).Sort.SortFields.Clear
    ActiveWorkbook.Worksheets(17).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(17).ListObjects(1).Name & "[QuarterSerial]"), SortOn:=xlSortOnValues, Order:= _
        xlAscending, DataOption:=xlSortNormal
    ActiveWorkbook.Worksheets(17).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(17).ListObjects(1).Name & "[Transaction Code]"), SortOn:=xlSortOnValues, Order:= _
        xlAscending, DataOption:=xlSortNormal
    ActiveWorkbook.Worksheets(17).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(17).ListObjects(1).Name & "[Absolute Value]"), SortOn:=xlSortOnValues, Order:= _
        xlDescending, DataOption:=xlSortNormal
    ActiveWorkbook.Worksheets(17).ListObjects(1).Sort.SortFields.Add2 Key:=Range(Worksheets(17).ListObjects(1).Name & "[Description]"), SortOn:=xlSortOnValues, Order:= _
        xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets(17).ListObjects(1).Sort
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    
    Set oLo = Worksheets(17).ListObjects(1)
        With oLo
    For l = 1 To .ListRows.Count

note = "Retired - No Coverage"
        If .ListColumns("Transaction Type").DataBodyRange(l, 1).Value = "Retirement" Then
            .ListColumns("TriMedx Coverage").DataBodyRange(l, 1).Value = note
        End If

note = "All Parts & Labor"
        If .ListColumns("TriMedx Coverage").DataBodyRange(l, 1).Value = "Missing Coverage" Then
            .ListColumns("TriMedx Coverage").DataBodyRange(l, 1).Value = note
        End If
        
        Next l

        End With
        
'Change Header to Proration Date'
    Rows("1:1").Replace What:="*Proration Date*", Replacement:="Proration Date", LookAt _
        :=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
        
    LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column
        For i = 1 To LastColumn
    If UCase(Cells(1, i)) = "CEID" Or UCase(Cells(1, i)) = "SERIAL" Or UCase(Cells(1, i)) = "RETIRED DATE" Or UCase(Cells(1, i)) = "PRORATION DATE" Then Columns(i).Hidden = True
        Next
    
ActiveSheet.ResetAllPageBreaks
  
    Set hdr = Rows(1).Find("Transaction Date", , xlValues, xlWhole, , , False)
        If Not hdr Is Nothing Then
    Set r = Columns(hdr.Column)
    Set f = r.Find("*Total*", , xlValues, xlPart, , , False)
        If Not f Is Nothing Then
            cell = f.Address
        Do
            f.Offset(1).PageBreak = xlPageBreakManual
        Set f = r.FindNext(f)
        
      Loop While Not f Is Nothing And f.Address <> cell
      
    End If
    
  End If
     
Dim ws17 As Worksheet

Set ws17 = Worksheets(17)
Set oLo = ws17.ListObjects(1)

With oLo
    For i = 1 To .ListRows.Count
        If .ListColumns("Annual Service Price").DataBodyRange.Cells(i, 1).Value = 0 Then
            If InStr(.ListColumns("Transaction Date").DataBodyRange.Cells(i, 1).Value, "Total") = 0 Then
                ws17.Rows(oLo.HeaderRowRange.Row + i).Hidden = True
            End If
        End If
    Next i
End With

    Sheets("Cover Page").Select
    Range("O1").Select

Application.Calculation = xlAutomatic
Application.ScreenUpdating = False
Application.EnableEvents = True
        
End Sub
 
I believe the majority of the macro is being spent with the loops
No doubt in the world about that.

How about you share a workbook with at least the largest of those *Transaction* sheets
so we can see what you're actually work with, I suspect things can be improved.
 
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I agree. Having something to test on could almost positively ensure the speedup.
 
Upvote 0
No doubt in the world about that.

How about you share a workbook with at least the largest of those *Transaction* sheets
so we can see what you're actually work with, I suspect things can be improved.
Okay! I will get on that this weekend and share with you here!

Again thank you all for helping out with this.
 
Upvote 0
No doubt in the world about that.

How about you share a workbook with at least the largest of those *Transaction* sheets
so we can see what you're actually work with, I suspect things can be improved.
Are there other recommended ways to share a workbook on here thats no XL2BB? My sheet is much greater than 3000 records so I can either trim it down significantly or find a different way to share a worksheet with yall.

Test.xlsx
EFGHIJKLMNOPQRSTU
1CustomerDepartmentCEIDSerialManufacturerModelDescriptionTriMedx CoverageTransaction TypeEntered DateWarranty EndRetired DateProration date Transaction Date Annual Service Price FY Effective Price Budgeted?
2ST VINCENTS EASTLABORATORY5007811627504SYSMEX AMERICA, INC.UF-1000I URINE ANALYZERS AUTOMATED Missing Coverage Addition8/5/20206/19/20216/19/2021$ 18,000$ 18,542Y
3ST VINCENTS EASTOR107301826641721071CARL ZEISSOPMI PENTERO 800 MICROSCOPES LIGHT OPERATING NEUROSURGERY All Parts & Labor Addition6/22/20206/22/20216/22/2021$ 15,000$ 15,329Y
4ST VINCENTS EASTCATH LAB982727(21)404824SIEMENS MEDICALACUSON SC2000 SCANNING SYSTEMS ULTRASONIC CARDIAC Missing Coverage Addition5/27/20205/27/20215/27/2021$ 13,000$ 14,211Y
5ST VINCENTS BLOUNTRADIOLOGY10497345205274XRFPGE MEDICAL SYSTEMSFLASHPAD HD 3543 DETECTORS X-RAY DIGITAL IMAGE All Parts & Labor Addition5/13/20205/13/20215/13/2021$ 8,800$ 9,957Y
6ST VINCENTS EASTCATH LAB50079506(21)20140020SIEMENS MEDICALZ6MS TRANSDUCERS ULTRASONIC TRANSESOPHAGEAL ECHOCARDIOGRAPHY Missing Coverage Addition5/27/20205/27/20215/27/2021$ 7,500$ 8,199Y
7ST VINCENTS EASTRADIOLOGY50077316193730100132CARESTREAM HEALTHDRX PLUS 3543C DETECTORS X-RAY DIGITAL IMAGE All Parts & Labor Addition5/19/20215/19/20225/19/2021$ 7,300$ 8,140N
8ST VINCENTS BLOUNTRADIOLOGY500828501033856WK4GE MEDICAL SYSTEMSOPTIMA XR220AMX RADIOGRAPHIC UNITS MOBILE DIGITAL Missing Coverage Addition5/13/20205/11/20215/11/2021$ 7,000$ 7,959Y
9ST VINCENTS EASTOR51291129LM00740BOSTON SCIENTIFICSWISS LITHOCLAST TRILOGY LITHOTRIPTERS All Parts & Labor Addition6/30/20216/30/2021$ 6,100$ 6,100N
10ST VINCENTS EASTOR500780861924MIZUHO OSITRIOS TABLES OPERATING SPINAL Missing Coverage Addition6/2/20206/2/20216/2/2021$ 5,200$ 5,599Y
11 Apr - Jun 21 Additions Total $ 87,900$ 94,036
12ST VINCENTS EASTBIOMED982504249325RAYSAFERAYSAFE X2 DOSIMETERS RADIATION All Parts & Labor Coverage Change11/20/201711/20/20184/1/2021$ (2,538)$ (3,163)N
13ST VINCENTS BLOUNTLABORATORY101990195220SAKURA FINETEK USATISSUE-TEK II CRYOSTAT MICROTOMES CRYOSTAT All Parts & Labor coverage change11/18/20156/14/2021$ 1,500$ 1,566N
14ST VINCENTS EASTBIOMED338983M102093 / sn 1331 in bat compartmtNETECHMINISIM SIMULATORS All Parts & Labor Coverage Change4/8/20154/1/2021$ (552)$ (688)N
15ST VINCENTS EASTREPROCESSINGEEG3474/72203967EEG3474SMITH & NEPHEWLENS - 72203967 VIDEO IMAGE PROCESSORS ENDOSCOPIC Documentation Only Coverage Change6/28/20176/28/20184/1/2021$ (396)$ (493)N
16ST VINCENTS EASTREPROCESSINGEEG3382/72203967EEG3382SMITH & NEPHEWLENS - 72203967 VIDEO IMAGE PROCESSORS ENDOSCOPIC Documentation Only Coverage Change6/28/20176/28/20184/1/2021$ (396)$ (493)N
17ST VINCENTS EASTANESTHESIA10161541BEJU05892DATEX OHMEDATEC 7 SEVO VAPORIZERS ANESTHESIA PM Labor Only coverage change2/3/20161/6/20155/10/2021$ (280)$ (319)N
18ST VINCENTS EASTWOUND SERVICES50026388R294AD4544HILL-ROMVERSACARE P3200 SERIES BEDS ELECTRIC FLOTATION THERAPY Documentation Only Coverage Change11/7/201611/4/20184/1/2021$ (264)$ (329)N
19ST VINCENTS EASTANESTHESIA587373BEJP11581DATEX OHMEDATEC 7 SEVO VAPORIZERS ANESTHESIA PM Labor Only coverage change5/3/20129/18/20135/10/2021$ (260)$ (296)N
20ST VINCENTS EASTANESTHESIA916180BEJP05630DATEX OHMEDATEC 7 SEVO VAPORIZERS ANESTHESIA PM Labor Only coverage change11/25/201411/23/20155/10/2021$ (260)$ (296)N
21ST VINCENTS ST CLAIRLABORATORY10457825F60C6718ALEREALERE I ANALYZERS LABORATORY MOLECULAR ASSAY Documentation Only Coverage Change12/9/20164/1/2021$ (223)$ (278)N
22 Apr - Jun 21 Coverage Changes Total $ (3,668)$ (4,792)
23ST VINCENTS EASTPRIMARY50097299H282AD1128HILL-ROMVERSACARE P3200 SERIES BEDS ELECTRIC FLOTATION THERAPY All Parts & Labor Transfer4/7/20117/1/20116/24/2021$ -$ -N
24ST VINCENTS EASTPRIMARY623674H282AD1158HILL-ROMVERSACARE P3200 SERIES BEDS ELECTRIC FLOTATION THERAPY All Parts & Labor Transfer4/4/20117/1/20116/24/2021$ -$ -N
25ST VINCENTS EASTBIOMED623732I029AD9877HILL-ROMVERSACARE P3200 SERIES BEDS ELECTRIC FLOTATION THERAPY All Parts & Labor Transfer4/4/20117/1/20116/10/2021$ -$ -N
26ST VINCENTS EASTBIOMED623715H298AD2342HILL-ROMVERSACARE P3200 SERIES BEDS ELECTRIC FLOTATION THERAPY All Parts & Labor Transfer4/4/20117/1/20116/10/2021$ -$ -N
27ST VINCENTS EASTBIOMED623685I016AD8576HILL-ROMVERSACARE P3200 SERIES BEDS ELECTRIC FLOTATION THERAPY All Parts & Labor Transfer4/4/20117/1/20116/10/2021$ -$ -N
28 Apr - Jun 21 Transfers Total $ -$ -
29ST VINCENTS EASTRADIOLOGY982746155330100505CARESTREAM HEALTHDRX CORE 3543C DETECTORS X-RAY DIGITAL IMAGE All Parts & Labor Retirement1/1/20195/19/20215/19/2021$ (7,410)$ (8,262)N
30ST VINCENTS EASTOR372980174694SIEMENS MEDICALARCADIS VARIC RADIOGRAPHIC/FLUOROSCOPIC UNITS MOBILE Retired - No Coverage Retirement1/10/20086/25/20216/25/2021$ (7,207)$ (7,305)N
31ST VINCENTS EASTREPROCESSING2042049A/LTF-VP2042049AOLYMPUS AMERICALTF-VP LAPAROSCOPES VIDEO Retired - No Coverage Retirement10/2/201910/2/20204/19/20214/19/2021$ (5,116)$ (6,125)N
32ST VINCENTS EASTREPROCESSING2041960B/LTF-VH2041960BOLYMPUS AMERICALTF-VH LAPAROSCOPES VIDEO Retired - No Coverage Retirement1/29/20201/28/20214/29/20214/29/2021$ (5,116)$ (5,985)N
33ST VINCENTS EASTREPROCESSING5000314756/8966.4015000314756RICHARD WOLF MEDICAL8966.401 NEPHROSCOPES RIGID Retired - No Coverage Retirement5/15/20187/8/20184/1/20214/1/2021$ (3,045)$ (3,796)N
34ST VINCENTS EASTCATH LAB3718942190AVOX SYSTEMSAVOXIMETER 1000E OXIMETERS IN VITRO LABORATORY Missing Coverage Retirement1/10/20086/8/20216/8/2021$ -$ -N
35ST VINCENTS EASTSICU50025816D123AM0214HILL-ROMTOTALCARE BEDS ELECTRIC LOW AIR LOSS Missing Coverage Retirement8/20/20116/8/20216/8/2021$ -$ -N
36ST VINCENTS EASTSICU987254D105AB7486HILL-ROMADVANTA BEDS ELECTRIC Missing Coverage Retirement8/20/20116/10/20216/10/2021$ -$ -N
37ST VINCENTS EASTMICU981659D122AM0180HILL-ROMTOTALCARE BEDS ELECTRIC LOW AIR LOSS Missing Coverage Retirement1/6/20126/9/20216/9/2021$ -$ -N
38ST VINCENTS EASTCICU982251C215AM3929HILL-ROMTOTALCARE BEDS ELECTRIC LOW AIR LOSS Missing Coverage Retirement8/20/20116/10/20216/10/2021$ -$ -N
39 Apr - Jun 21 Retirements Total $ (27,892)$ (31,472)
FY22 Transactions
Cell Formulas
RangeFormula
T2:T10,T29:T38,T23:T27,T12:T21T2=IFERROR(([@[Annual Service Price]]/365)*('S:\TriMedx_Units\Customer Accounts\Ascension Health\STVINCENTEAST- Eastern Health Services-Birmingham, AL\FY22\FY22 Q3\Customer Summary\[FY22 Q3 East Overall CS with FY23 Updates.xlsm]Cover Page'!$AN$20-[@[Transaction Date]]),0)+[@[Proration amt]]
U2:U10,U29:U38,U23:U27,U12:U21U2=IFERROR(VLOOKUP([@CEID],'S:\TriMedx_Units\Customer Accounts\Ascension Health\STVINCENTEAST- Eastern Health Services-Birmingham, AL\FY22\FY22 Q3\Customer Summary\FY22 Q3 East Overall CS with FY23 Updates.xlsm'!FY22BudgetTable[[CEID]:[Budgeted]],18,FALSE),"N")
R11R11='S:\TriMedx_Units\Customer Accounts\Ascension Health\STVINCENTEAST- Eastern Health Services-Birmingham, AL\FY22\FY22 Q3\Customer Summary\[FY22 Q3 East Overall CS with FY23 Updates.xlsm]Cover Page'!AD5&" Additions Total"
S11:T11S11=SUM(S2:S10)
R22R22='S:\TriMedx_Units\Customer Accounts\Ascension Health\STVINCENTEAST- Eastern Health Services-Birmingham, AL\FY22\FY22 Q3\Customer Summary\[FY22 Q3 East Overall CS with FY23 Updates.xlsm]Cover Page'!AD5&" Coverage Changes Total"
S22:T22,S39:T39S22=SUM(S12:S21)
R28R28='S:\TriMedx_Units\Customer Accounts\Ascension Health\STVINCENTEAST- Eastern Health Services-Birmingham, AL\FY22\FY22 Q3\Customer Summary\[FY22 Q3 East Overall CS with FY23 Updates.xlsm]Cover Page'!AD5& " Transfers Total"
S28:T28S28=SUM(S23:S27)
R39R39='S:\TriMedx_Units\Customer Accounts\Ascension Health\STVINCENTEAST- Eastern Health Services-Birmingham, AL\FY22\FY22 Q3\Customer Summary\[FY22 Q3 East Overall CS with FY23 Updates.xlsm]Cover Page'!AD5&" Retirements Total"
Cells with Conditional Formatting
CellConditionCell FormatStop If True
T23Expression=$AA26>QUARTERDIGITtextNO
T24Expression=$AA27>QUARTERDIGITtextNO
S23Expression=$AA26>QUARTERDIGITtextNO
S24Expression=$AA27>QUARTERDIGITtextNO
3:3,A2:K2,M2:XFD2Expression=#REF!>QUARTERDIGITtextNO
27:27Expression=#REF!>QUARTERDIGITtextNO
13:13Expression=#REF!>QUARTERDIGITtextNO
7:7Expression=#REF!>QUARTERDIGITtextNO
A24:R24,U24:XFD24Expression=#REF!>QUARTERDIGITtextNO
17:17Expression=#REF!>QUARTERDIGITtextNO
29:30Expression=#REF!>QUARTERDIGITtextNO
20:21Expression=#REF!>QUARTERDIGITtextNO
33:33Expression=#REF!>QUARTERDIGITtextNO
35:36Expression=#REF!>QUARTERDIGITtextNO
11:11,22:22,28:28Expression=$AA12>QUARTERDIGITtextNO
5:5,A4:K4,M4:XFD4Expression=$AA11>QUARTERDIGITtextNO
31:31Expression=$AA39>QUARTERDIGITtextNO
9:9,A8:K8,M8:XFD8Expression=$AA22>QUARTERDIGITtextNO
A23:R23,U23:XFD23Expression=$AA27>QUARTERDIGITtextNO
16:16Expression=$AA27>QUARTERDIGITtextNO
25:26Expression=$AA28>QUARTERDIGITtextNO
18:19Expression=$AA28>QUARTERDIGITtextNO
12:12Expression=#REF!>QUARTERDIGITtextNO
A6:K6,M6:XFD6Expression=#REF!>QUARTERDIGITtextNO
39:39Expression=#REF!>QUARTERDIGITtextNO
32:32Expression=#REF!>QUARTERDIGITtextNO
34:34Expression=#REF!>QUARTERDIGITtextNO
L10,L8,L6,L4,L2Expression=#REF!>QUARTERDIGITtextNO
37:38Expression=#REF!>QUARTERDIGITtextNO
M10:XFD10,A10:K10Expression=$AA27>QUARTERDIGITtextNO
14:15Expression=$AA22>QUARTERDIGITtextNO
Cells with Data Validation
CellAllowCriteria
M23:M27ListAddition,Retirement, Coverage Change, Transfer
M2:M10ListAddition,Retirement, Coverage Change, Transfer
M12:M21ListAddition,Retirement, Coverage Change, Transfer
M29:M38ListAddition, Retirement, Coverage Change, Transfer
 
Upvote 0
other recommended ways to share a workbook
I don't know what your time zone overlap is with Johnny and NoSparks, so in case it helps keep it moving for when they come back online, the other method of sharing is to put the workbook on one of the sharing platforms such as googledrive, onedrive, dropbox. Make it available to anyone with the link and then post the link here.

I will leave working on the code with them.
 
Upvote 0
Well I was trying to use an array: Load array with DataBodyRange contents ... This part works. I make changes to the array. This part works.

The problem I encounter is that I get a run time error 1004 when attempting to write the array back to the table. :(

I don't hardly use Tables for the most part so I am not really familiar with them.

To load the array I use:
VBA Code:
        TableArray = ActiveSheet.ListObjects(1).DataBodyRange                                                   ' Save table into TableArray without header

but error 1004 when trying to write it back to the table:
VBA Code:
        ActiveSheet.ListObjects(1).DataBodyRange = TableArray                                                   ' Save TableArray back into the table

Maybe someone can chime in as to why this doesn't work and a way to make it work.
 
Upvote 0
The time consuming loops are code I gave the OP in responses to other questions.
I think I've got it changed to filters which wouldn't be as fast as arrays but may be acceptable,
and likely easier to understand should future amendments be required.

Just waiting for a file to test with.
 
Upvote 0
Thanks bmkelly, got it.
Had a quick try and am having an issue with the filtering that needs rectified.
Now going to a one grandson's soccer game and another's hockey game so likely won't get back at this until tomorrow.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top