Dynamic Sum of Data

  • i Created a sheet that dynamically insert column based on different Cell Values but am not able to Sum the data


    code [VBA]Sub LoopDates()


    With Sheets("OrderReview")
    lastCol = Cells(2, .Columns.Count).End(xlToLeft).Column - 1


    Range("Q1:CL1") = "=WEEKNUM(R[1]C)&YEAR(R[1]C)"
    Rows("1:1").Select
    Selection.Font.Bold = True


    For a = lastCol To 17 Step -1
    If Cells(1, a) <> Cells(1, a - 1) Then
    Application.DisplayAlerts = False
    .Columns(a).Insert
    .Columns(a).ColumnWidth = 12
    .Cells(Rows.Count, a).End(xlUp).Borders(xlEdgeRight).LineStyle = xlContinuous
    .Cells(2, a).Value = .Cells(2, a + 1).Value
    .Cells(1, a).Value = "=WEEKNUM(R[1]C)&YEAR(R[1]C)"
    .Cells(1, a).Font.Bold = False
    .Cells(2, a).Font.Bold = False
    End If
    Next a



    End With



    Application.DisplayAlerts = True
    End Sub[/VBA]


    i want to sum all data in rows
    Note: Un-Bold Fields are Inserted By Macro
    i need to Sum All Data in Rows after inserting the Column ( Sum all With Row1 = 482018)
    your help is appreciated


    Sum(all Rows That has same ROW1 )


    [ATTACH=JSON]{"alt":"Click image for larger version Name:\tSample.jpg Views:\t2 Size:\t115.0 KB ID:\t1208105","data-align":"none","data-attachmentid":"1208105","data-size":"full","title":"Sample.jpg"}[/ATTACH]

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!