+ Reply to Thread
Results 1 to 5 of 5

Thread: VBA help - Autosum/sum by date change

  1. #1
    Registered User
    Join Date
    09-22-2011
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    4

    VBA help - Autosum/sum by date change

    I am trying to auto sum or sum the totals for Hours, QTY and Amount
    in the row below the data. i already have the code to insert a new row on date change, my next step is to place "Daily Total" in Range("A") of the inserted Row, and then sum/autosum the other columns with values.

    Data example is as follows

    A B C D E F G
    Date Campaign Outcome Rate Hours QTY Amount
    22/09/2011, #####, Activity, 20.00, 5 , , 100.00
    22/09/2011, #####, Collection, 0.50, , 1, 0.50

    23/09/2011, #####, Activity, 19.00, 1 , , 19.00

    24/09/2011, #####, Activity, 20.00, 2 , 40.00
    24/09/2011, #####, Collection, 0.50, , 2, 1.00
    24/09/2011, #####, Collection2, 1.00, , 4, 4.00

    appologies for the spacing of the data, unsure how to post data correctly.. as paste doesnt seem to work.. i have seperated columns using comma's if it helps.

    The code i have so far...

    Dim lastRow, chkRw As Integer
        lastRow = Range("A" & Rows.Count).End(xlUp).Row
    
    For chkRw = lastRow To 4 Step -1
        If Range("A" & chkRw) <> Range("A" & chkRw + 1) Then
           Range("A" & chkRw + 1).EntireRow.Insert shift:=xlDown
        End If
         
    
       Next
    Any help would be greatly appreciated
    Last edited by T-rev; 09-22-2011 at 02:00 AM.

  2. #2
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,640

    Re: VBA help - Autosum/sum by date change

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  3. #3
    Registered User
    Join Date
    09-22-2011
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: VBA help - Autosum/sum by date change

    Quote Originally Posted by royUK View Post
    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    sure, sorry i didnt know how to add a workbook, now i see..

    please note that the data does change, every new sheet imported may have different numbers of rows for different dates, (more Entries of "Activity" or "Collected")

    have attached dummy workbooks for you.....
    Forum example Before.xlsm
    Forum example After.xlsm
    Last edited by T-rev; 09-22-2011 at 08:49 AM.

  4. #4
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,640

    Re: VBA help - Autosum/sum by date change

    If you removed the completely empty rows in your data then you could use a PivotTable
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  5. #5
    Registered User
    Join Date
    09-22-2011
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: VBA help - Autosum/sum by date change

    would rather not, the idea is the data is imported from another program (which exports to excel) but is completely locked for editing.. so the macro is to copy the data to a new worksheet which it does, and then format it accordingly so the raw data can be used for another spreadsheet later in the process..

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0