+ Reply to Thread
Results 1 to 28 of 28

Populate report from date to date for many ID

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    732

    Populate report from date to date for many ID

    Hello
    I search for macro to deal for each sheet .
    in two sheets I have data for items in columns D:F and the price in column H . so what I want when merge duplicates items based on matching columns D: F and when repeat the same item with different price should use price averages but when merge items should be separated for each sheet alone , also when merge quantity should just be for SVR sheet (means ignoring QTY totally in SR sheet when merge as I did last sheet .
    when merge data should be based on two cells (dates) should merge within two dates in E2,G2 . if the E2,G2 are empty then should be empty from row 5 .every time run the macro should clear data from row5 before brings the data without delete formatting and borders , not repeat to the bottom the same data have already copied.
    in REPORT sheet SVR header is averages prices from column H for SVR sheet ,SR header is averages prices from column H for SR sheet and in last row(TOTAL) should sum the columns I,J,K and in column L will subtract and sum for I:K as I put the formulas .
    if they data are existed in SVR but not in SR should show in REPORT sheet , but if they data are existed in SR ,not in SVR should NOT show in REPORT sheet .
    finally when copy data to report sheet I want keep the formatting (numbers,borders....) .
    thanks
    Attached Files Attached Files
    Last edited by abdo meghari; 12-06-2023 at 08:43 AM.

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,520

    Re: Populate report from date to date for many ID

    Hey there abdo...
    The date population part I do not understand...
    This renders your expected result though...
    Attached Files Attached Files
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    732

    Re: Populate report from date to date for many ID

    Hi sintek
    The date population part I do not understand...
    I want creating report based on two dates . should not merge for all ID without depend on two dates .
    just merge based what data start and end date also between two dates and ignore merging before start date and after end date and when dates cells are empty then should not show anything
    edited file to understand how could be
    Last edited by abdo meghari; 12-06-2023 at 06:17 AM.

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,520

    Re: Populate report from date to date for many ID

    Yet you do not provide the between dates?

  5. #5
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    732

    Re: Populate report from date to date for many ID

    Yet you do not provide the between dates?
    sorry !
    would you see edited file,please?

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,520

    Re: Populate report from date to date for many ID

    Need an entire different code approach for this...Will revert back a bit later...Off to work now...

  7. #7
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,520

    Re: Populate report from date to date for many ID

    Based on these dates, your output result is incorrect...
    Last edited by Sintek; 12-06-2023 at 06:57 AM.

  8. #8
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    732

    Re: Populate report from date to date for many ID

    Based on these dates, your output result is incorrect...
    OMG!
    sorry again I was hurry .
    it's corrected.

  9. #9
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,520

    Re: Populate report from date to date for many ID

    And another error...see green value below...

    Untitled.png
    Attached Files Attached Files
    Last edited by Sintek; 12-06-2023 at 07:07 AM.

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,589

    Re: Populate report from date to date for many ID

    Option Explicit
    
    Sub Demo()
        Dim ar As Variant, arr As Variant
        Dim i As Long, j As Long, k As Long, n As Long
        Dim str As String
        Dim sdate As Date, fdate As Date
        Dim ws()
        ws = Array("SVR", "SR")
        ReDim arr(1 To 100, 1 To 10)
        
        With Sheets("Report")
            sdate = .[E2]: fdate = .[G2]
        End With
        
        n = 0
        
        With CreateObject("Scripting.Dictionary")
        
            For j = 0 To 1
            
                With Sheets(ws(j))
                    ar = .Cells(1, 1).Offset(1, 0).CurrentRegion
                End With
                
                For i = 2 To UBound(ar, 1)
                
                   If ar(i, 2) >= sdate And ar(i, 2) <= fdate Then
                
                    str = ar(i, 4) & ar(i, 5) & ar(i, 6)
                    If str <> vbNullString Then
                        If Not .Exists(str) Then
                            n = n + 1
                           .Add str, n
                           .Item(str) = n
                            arr(n, 1) = n
                            For k = 4 To 6
                                arr(n, k - 2) = ar(i, k)
                            Next k
                            arr(n, 5) = arr(n, 5) + ar(i, 7)
                            arr(n, 6) = arr(n, 6) + ar(i, 8)
                            arr(n, 9) = arr(n, 9) + 1
                            
                        Else
                             If j = 0 Then
                                arr(.Item(str), 5) = arr(.Item(str), 5) + ar(i, 7)
                                arr(.Item(str), 6) = arr(.Item(str), 6) + ar(i, 8)
                                arr(.Item(str), 9) = arr(.Item(str), 9) + 1
                             Else
                                arr(.Item(str), 7) = arr(.Item(str), 7) + ar(i, 8)
                                arr(.Item(str), 10) = arr(.Item(str), 10) + 1
                             End If
                        End If
                    End If
                  End If
                Next i
                
            Next j
        End With
        
        For j = 1 To n
            arr(j, 6) = arr(j, 6) / arr(j, 9)
            If arr(j, 10) > 0 Then arr(j, 7) = arr(j, 7) / arr(j, 10) Else arr(j, 7) = 0
            arr(j, 8) = (arr(j, 6) - arr(j, 7)) * arr(j, 5)
        Next j
            
        
        With Sheets("Report")
            .[E4].CurrentRegion.Clear
            .[E4].Resize(1, 8) = Array("ITEM", "BRAND", "TYPE", "ORIGIN", "QTY", "SVR", "SR", "NET")
            .[E4].Resize(1, 8).Font.Bold = True
            .[E5].Resize(n, 8) = arr
            .Cells(5 + n, 5) = "TOTAL": .Cells(5 + n, 5).Font.Bold = True
            .Cells(5 + n, 9).Resize(, 3).Formula = "=SUM(I5:I" & 5 + n - 1 & ")"
            .Cells(5 + n, 12) = .Cells(5 + n, 9) * .Cells(5 + n, 10) - .Cells(5 + n, 11)
            .[E4].Resize(n + 2, 8).Borders.Weight = 2
            .Columns(10).Resize(, 3).NumberFormat = "#0,0.00"
            .Columns(5).Resize(, 8).HorizontalAlignment = xlCenter
        End With
    End Sub
    Attached Files Attached Files
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  11. #11
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    732

    Re: Populate report from date to date for many ID

    And another error...see green value below...
    understood , sorry again !
    as to your new version seem this is what I want , but I need some time to make sure .
    I will inform you today .

  12. #12
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    732

    Re: Populate report from date to date for many ID

    Hi JohnTopley ,
    thanks but I note your code showing new ID in SR sheet but is not existed in SVR sheet also when the ID is not existed in SVR sheet within date I note showing .
    the highlighted rows shouldn't show based on dates.
    Attached Files Attached Files

  13. #13
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,589

    Re: Populate report from date to date for many ID

    See attached

    Option Explicit
    
    Sub Demo()
        Dim ar As Variant, arr As Variant
        Dim i As Long, j As Long, k As Long, n As Long
        Dim str As String
        Dim sdate As Date, fdate As Date
        Dim ws()
        ws = Array("SVR", "SR")
        ReDim arr(1 To 100, 1 To 10)
        
        With Sheets("Report")
            sdate = .[E2]: fdate = .[G2]
        End With
        
        n = 0
        
        With CreateObject("Scripting.Dictionary")
        
            For j = 0 To 1
            
                With Sheets(ws(j))
                    ar = .Cells(1, 1).Offset(1, 0).CurrentRegion
                End With
                
                For i = 2 To UBound(ar, 1)
                
                   If ar(i, 2) >= sdate And ar(i, 2) <= fdate Then
                
                    str = ar(i, 4) & ar(i, 5) & ar(i, 6)
                    If str <> vbNullString Then
                          If Not .Exists(str) Then
                               If j = 1 Then GoTo nexti
                                n = n + 1
                               .Add str, n
                               .Item(str) = n
                                arr(n, 1) = n
                                For k = 4 To 6
                                    arr(n, k - 2) = ar(i, k)
                                Next k
                                arr(n, 5) = arr(n, 5) + ar(i, 7)
                                arr(n, 6) = arr(n, 6) + ar(i, 8)
                                arr(n, 9) = arr(n, 9) + 1
                                
                            Else
                                 If j = 0 Then
                                    arr(.Item(str), 5) = arr(.Item(str), 5) + ar(i, 7)
                                    arr(.Item(str), 6) = arr(.Item(str), 6) + ar(i, 8)
                                    arr(.Item(str), 9) = arr(.Item(str), 9) + 1
                                 Else
                                    arr(.Item(str), 7) = arr(.Item(str), 7) + ar(i, 8)
                                    arr(.Item(str), 10) = arr(.Item(str), 10) + 1
                                 End If
                             End If
                        End If
                    End If
                  
    nexti:
                Next i
                
            Next j
        End With
        
        For j = 1 To n
            arr(j, 6) = arr(j, 6) / arr(j, 9)
            If arr(j, 10) > 0 Then arr(j, 7) = arr(j, 7) / arr(j, 10) Else arr(j, 7) = 0
            arr(j, 8) = (arr(j, 6) - arr(j, 7)) * arr(j, 5)
        Next j
            
        
        With Sheets("Report")
            .[E4].CurrentRegion.Clear
            .[E4].Resize(1, 8) = Array("ITEM", "BRAND", "TYPE", "ORIGIN", "QTY", "SVR", "SR", "NET")
            .[E4].Resize(1, 8).Font.Bold = True
            .[E5].Resize(n, 8) = arr
            .Cells(5 + n, 5) = "TOTAL": .Cells(5 + n, 5).Font.Bold = True
            .Cells(5 + n, 9).Resize(, 3).Formula = "=SUM(I5:I" & 5 + n - 1 & ")"
            .Cells(5 + n, 12) = .Cells(5 + n, 9) * .Cells(5 + n, 10) - .Cells(5 + n, 11)
            .[E4].Resize(n + 2, 8).Borders.Weight = 2
            .Columns(10).Resize(, 3).NumberFormat = "#0,0.00"
            .Columns(5).Resize(, 8).HorizontalAlignment = xlCenter
        End With
    End Sub
    Attached Files Attached Files
    Last edited by JohnTopley; 12-06-2023 at 04:18 PM.

  14. #14
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    732

    Re: Populate report from date to date for many ID

    Thanks sintek & john !
    just remains one thing : if the E2,G2 are empty then should be empty from row 5 . as I mentioned in OP.

  15. #15
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,589

    Re: Populate report from date to date for many ID

    Why would you run macro with these fields empty ?

    With Sheets("Report")
            sdate = .[E2]: fdate = .[G2]
            If sdate = 0 Then
                .Range("E5:L" & .Cells(Rows.Count, "E").End(xlUp).Row).Clear
                 Exit Sub
            End If
        End With

  16. #16
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,520

    Re: Populate report from date to date for many ID

    Sub J3v16v2()
    Dim ShtArr, Data, Chk, X0, X1, X2, Temp, StDt As Date, EdDt As Date
    Dim Dict As Object, Str As String, i As Long, ii As Long, x As Long
    ShtArr = [{"SVR","SR"}]: Set Dict = CreateObject("Scripting.Dictionary")
    ReDim Temp(1 To 1000, 1 To 7)
    With Sheets("Report")
        StDt = .Range("E2"): EdDt = .Range("G2")
        If StDt = 0 Then .Rows(5 & ":" & .Rows.Count).Delete
        Exit Sub
    End With
    For i = 1 To 2
        With Sheets(ShtArr(i)).Cells(1).CurrentRegion
            Data = .Value
            For ii = 2 To UBound(Data)
                If Data(ii, 4) <> "" Then
                    Str = Data(ii, 4) & Data(ii, 5) & Data(ii, 6)
                    X0 = Application.CountIfs(.Columns(4), Data(ii, 4), .Columns(5), Data(ii, 5), .Columns(6), Data(ii, 6), .Columns(2), ">=" & "" & CDbl(StDt) & "", .Columns(2), "<=" & "" & CDbl(EdDt) & "")
                    If X0 > 0 Then
                        If i = 2 Then
                            With Sheets(ShtArr(i - 1)).Cells(1).CurrentRegion
                                X0 = Application.CountIfs(.Columns(4), Data(ii, 4), .Columns(5), Data(ii, 5), .Columns(6), Data(ii, 6), .Columns(2), ">=" & "" & CDbl(StDt) & "", .Columns(2), "<=" & "" & CDbl(EdDt) & "")
                                If X0 = 0 Then GoTo Nxt
                            End With
                        End If
                        X1 = Application.SumIfs(.Columns(7), .Columns(4), Data(ii, 4), .Columns(5), Data(ii, 5), .Columns(6), Data(ii, 6), .Columns(2), ">=" & "" & CDbl(StDt) & "", .Columns(2), "<=" & "" & CDbl(EdDt) & "")
                        X2 = Application.SumIfs(.Columns(8), .Columns(4), Data(ii, 4), .Columns(5), Data(ii, 5), .Columns(6), Data(ii, 6), .Columns(2), ">=" & "" & CDbl(StDt) & "", .Columns(2), "<=" & "" & CDbl(EdDt) & "") / X0
                        If Not Dict.exists(Str) Then
                            Dict.Add Str, "": x = x + 1
                            Temp(x, 1) = Str: Temp(x, 2) = Data(ii, 4)
                            Temp(x, 3) = Data(ii, 5): Temp(x, 4) = Data(ii, 6)
                            Temp(x, 5) = X1: Temp(x, IIf(i = 1, 6, 7)) = X2
                        Else
                            If i = 2 Then Chk = Application.Match(Str, Application.Index(Temp, , 1), 0): Temp(Chk, 7) = X2
                        End If
                    End If
                End If
    Nxt:
            Next ii
        End With
    Next i
    With Sheets("Report")
        .Rows(5 & ":" & .Rows.Count).Delete
        .Cells(5, 5).Resize(x, 7) = Temp
        .Cells(5, 5).Resize(x).Value = Evaluate("Row(1:" & x & ")")
        .Cells(5, 12).Resize(x + 1).Formula = "=I5*J5-K5"
        .Cells(5, 10).Resize(x + 1, 3).NumberFormat = "#,0.00"
        .Cells(5 + x, 9).Resize(, 3).Formula = "=SUM(I5:I" & 5 + x - 1 & ")"
        .Cells(5 + x, 5) = "TOTAL"
        With .Cells(5, 5).CurrentRegion
            .Columns(7).SpecialCells(xlCellTypeBlanks) = 0
            .Borders.Weight = 2
            .Columns(1).Font.Bold = True
            .HorizontalAlignment = xlCenter
        End With
    End With
    End Sub
    Last edited by Sintek; 12-07-2023 at 01:33 AM.

  17. #17
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    732

    Re: Populate report from date to date for many ID

    thanks John , but after clear data when there is no date and try write dates again to populate data will shows application defined error in this line
    .[E5].Resize(n, 8) = arr

  18. #18
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,589

    Re: Populate report from date to date for many ID

    I don't have any problem deleting the dates and then adding dates again!

    You will get an error if there is no data in the dates used.

    Add highlighted line

     If n = 0 Then Exit Sub
        
        For j = 1 To n
            arr(j, 6) = arr(j, 6) / arr(j, 9)
            If arr(j, 10) > 0 Then arr(j, 7) = arr(j, 7) / arr(j, 10) Else arr(j, 7) = 0
            arr(j, 8) = (arr(j, 6) - arr(j, 7)) * arr(j, 5)
        Next j
    Last edited by JohnTopley; 12-07-2023 at 03:43 AM.

  19. #19
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    732

    Re: Populate report from date to date for many ID

    thanks sintek , but but after clear data when there is no date and try writing dates again , then it doesn't show data. the cells keep empty from row 5!

  20. #20
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,520

    Re: Populate report from date to date for many ID

    oops...my bad...
    If StDt = 0 Then .Rows(5 & ":" & .Rows.Count).Delete: Exit Sub

  21. #21
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    732

    Re: Populate report from date to date for many ID

    You will get an error if there is no data in the dates used.
    umm, thanks for your notice , but your suggestion will cancel option in post #15

  22. #22
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,589

    Re: Populate report from date to date for many ID

    No it does not: if you do not enter dates it will clear the data but if you enter dates for which there is no results then the added test will/should prevent the error.

    I am out!

  23. #23
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    732

    Re: Populate report from date to date for many ID

    you can test it yourself .
    Attached Files Attached Files

  24. #24
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,589

    Re: Populate report from date to date for many ID

    Wrong (not updated) macro: see post #15.

  25. #25
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    732

    Re: Populate report from date to date for many ID

     With Sheets("Report")
         sdate = .[E2]: fdate = .[G2]
            If sdate = 0 Then
                .Range("E5:L" & .Cells(Rows.Count, "E").End(xlUp).Row).Clear
                 Exit Sub
            End If
            .[E4].CurrentRegion.Clear
    '
    '
    '
    is that wrong place?

  26. #26
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,589

    Re: Populate report from date to date for many ID

    YES:

    Sub Demo()
        Dim ar As Variant, arr As Variant
        Dim i As Long, j As Long, k As Long, n As Long
        Dim str As String
        Dim sdate As Date, fdate As Date
        Dim ws()
        ws = Array("SVR", "SR")
        ReDim arr(1 To 100, 1 To 10)
        
        With Sheets("Report")
            sdate = .[E2]: fdate = .[G2]
            If sdate = 0 Then
                .Range("E5:L" & .Cells(Rows.Count, "E").End(xlUp).Row).Clear
                 Exit Sub
            End If
        End With
        
        
        n = 0
        
        With CreateObject("Scripting.Dictionary")
        
            For j = 0 To 1
            
                With Sheets(ws(j))
                    ar = .Cells(1, 1).Offset(1, 0).CurrentRegion
                End With
                
                For i = 2 To UBound(ar, 1)
                
                   If ar(i, 2) >= sdate And ar(i, 2) <= fdate Then
                
                    str = ar(i, 4) & ar(i, 5) & ar(i, 6)
                    If str <> vbNullString Then
                          If Not .Exists(str) Then
                               If j = 1 Then GoTo nexti
                                n = n + 1
                               .Item(str) = n
                                arr(n, 1) = n
                                For k = 4 To 6
                                    arr(n, k - 2) = ar(i, k)
                                Next k
                                arr(n, 5) = arr(n, 5) + ar(i, 7)
                                arr(n, 6) = arr(n, 6) + ar(i, 8)
                                arr(n, 9) = arr(n, 9) + 1
                                
                            Else
                                 If j = 0 Then
                                    arr(.Item(str), 5) = arr(.Item(str), 5) + ar(i, 7)
                                    arr(.Item(str), 6) = arr(.Item(str), 6) + ar(i, 8)
                                    arr(.Item(str), 9) = arr(.Item(str), 9) + 1
                                 Else
                                    arr(.Item(str), 7) = arr(.Item(str), 7) + ar(i, 8)
                                    arr(.Item(str), 10) = arr(.Item(str), 10) + 1
                                 End If
                             End If
                        End If
                    End If
                  
    nexti:
                Next i
                
            Next j
        End With
        
        If n = 0 Then Exit Sub
        
        For j = 1 To n
            arr(j, 6) = arr(j, 6) / arr(j, 9)
            If arr(j, 10) > 0 Then arr(j, 7) = arr(j, 7) / arr(j, 10) Else arr(j, 7) = 0
            arr(j, 8) = (arr(j, 6) - arr(j, 7)) * arr(j, 5)
        Next j
            
        
        With Sheets("Report")
            .[E4].CurrentRegion.Clear
            .[E4].Resize(1, 8) = Array("ITEM", "BRAND", "TYPE", "ORIGIN", "QTY", "SVR", "SR", "NET")
            .[E4].Resize(1, 8).Font.Bold = True
            .[E5].Resize(n, 8) = arr
            .Cells(5 + n, 5) = "TOTAL": .Cells(5 + n, 5).Font.Bold = True
            .Cells(5 + n, 9).Resize(, 3).Formula = "=SUM(I5:I" & 5 + n - 1 & ")"
            .Cells(5 + n, 12) = .Cells(5 + n, 9) * .Cells(5 + n, 10) - .Cells(5 + n, 11)
            .[E4].Resize(n + 2, 8).Borders.Weight = 2
            .Columns(10).Resize(, 3).NumberFormat = "#0,0.00"
            .Columns(5).Resize(, 8).HorizontalAlignment = xlCenter
        End With
    End Sub

  27. #27
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    732

    Re: Populate report from date to date for many ID

    thank you so much John

  28. #28
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    732

    Re: Populate report from date to date for many ID

    oops...my bad...
    no problem
    thank you so much for correction .

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 9
    Last Post: 06-11-2018, 07:17 AM
  2. [SOLVED] Date conversion - Excel presents system report date incorrectly
    By Fred Johs in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 02-02-2017, 10:26 AM
  3. Replies: 0
    Last Post: 01-30-2016, 11:49 AM
  4. Replies: 6
    Last Post: 04-20-2015, 09:40 AM
  5. Replies: 1
    Last Post: 05-26-2014, 03:46 AM
  6. Replies: 4
    Last Post: 04-24-2014, 04:34 AM
  7. Replies: 2
    Last Post: 06-25-2010, 09:19 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1