+ Reply to Thread
Results 1 to 7 of 7

VB Code to summarize weekly Sales

Hybrid View

rizmomin VB Code to summarize weekly... 09-16-2014, 01:26 PM
JieJenn Re: VB Code to summarize... 09-16-2014, 01:34 PM
JOHN H. DAVIS Re: VB Code to summarize... 09-16-2014, 02:32 PM
rizmomin Re: VB Code to summarize... 09-16-2014, 02:44 PM
JOHN H. DAVIS Re: VB Code to summarize... 09-16-2014, 03:03 PM
rizmomin Re: VB Code to summarize... 09-16-2014, 03:17 PM
JieJenn Re: VB Code to summarize... 09-16-2014, 03:52 PM
  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB Code to summarize weekly Sales

    Hello:

    Please refer to attached file.

    I have 2 sheets called Sales and Weekday.
    As you can see Sales for Daily are shown in column L of Sheet "Sales".

    I need a VB Code to summarize by Weeknum and day of the week as shown in "Weekday" Sheet.
    Would need the Week Start Date and Weekend Date in column B and C.
    I have manually completed for week 1
    FY: My week start from Fri and ends on Thu.


    Let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: VB Code to summarize weekly Sales

    Why not just go with formula.

    In E3 enter =SUMIFS(Sales!$L$3:$L$37,Sales!$A$3:$A$37,">="&B3,Sales!$A$3:$A$37,"<="&C3) and drag it down
    In F3 enter =SUMIFS(Sales!$L$3:$L$37,Sales!$A$3:$A$37,">="&$B3,Sales!$A$3:$A$37,"<="&$C3,Sales!$B$3:$B$37,F$2) drag it down and across
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VB Code to summarize weekly Sales

    FWIW:

    Sub rizmoninzz()
    Dim i As Long
    Dim rcell As Range
    With Application
        .Calculation = xlCalculationManual
        .ScreenUpdating = False
    End With
    For i = Range("D" & Rows.count).End(3).Row To 3 Step -1
        If Range("D" & i) <> Range("D" & i + 1) Then
            Rows(i + 1).Insert
        End If
    Next i
    For Each numrange In Columns("L").SpecialCells(xlConstants, xlNumbers).Areas
        SUMADDR = numrange.address(False, False)
        Range(SUMADDR).Copy
        Sheets("Weekday").Range("F" & Rows.count).End(3)(2).PasteSpecial Transpose:=True
            C = numrange.count
    Next numrange
    NoData:
    For Each rcell In Range("D3:D" & Range("D" & Rows.count).End(3).Row)
        If Not IsNumeric(rcell.offset(-1)) Or rcell.offset(-1) = "" Then
            rcell.offset(, -3).Copy Sheets("Weekday").Range("B" & Rows.count).End(3)(2)
        End If
        If rcell.offset(1).Value = "" Then
            rcell.offset(, -3).Copy Sheets("Weekday").Range("C" & Rows.count).End(3)(2)
        End If
    Next rcell
    With Sheets("Weekday")
        For i = 3 To .Range("B" & Rows.count).End(3).Row
            With .Range("E" & i)
                .Formula = "=SUM(F" & i & ":L" & i & ")"
                .Value = .Value
            End With
        Next i
    End With
    Sheets("Sales").Range("A2:A" & Range("A" & Rows.count).End(3).Row).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    With Application
        .Calculation = xlCalculationAutomatic
        .ScreenUpdating = True
    End With
    End Sub

  4. #4
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to summarize weekly Sales

    Hi John:

    For some reason it seems not work.
    Please refer to attached file.
    Let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VB Code to summarize weekly Sales

    It works for me? Activate Sales and run it.

  6. #6
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to summarize weekly Sales

    Hi JieJenn:

    Looks like your solution will work great.
    i still need 1 more favor.
    I would i make column L variable so that i can choose which column i want to add.
    This way i can do multiple data study by choosing the column and see the data.
    Please Please let me know if you have any questions.
    Thanks.

    Riz

  7. #7
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: VB Code to summarize weekly Sales

    Just change the cell range reference. You have to do that also if you are going with VBA route.

+ 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. Summarize weekly Inventory
    By top1 in forum Excel General
    Replies: 9
    Last Post: 02-08-2010, 07:30 PM
  2. summarize monthly sales from daily sales
    By top1 in forum Excel General
    Replies: 4
    Last Post: 01-05-2010, 11:59 PM
  3. copy week total in weekly sales worksheet to appropriate week in monthly sales
    By Sandy2976 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-15-2009, 01:04 PM
  4. Summarize daily data into weekly average
    By agentred in forum Excel General
    Replies: 5
    Last Post: 01-19-2009, 06:48 AM
  5. Summarize employee attendance data on a weekly basis
    By Hanr3 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-05-2006, 12:00 PM

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