+ Reply to Thread
Results 1 to 7 of 7

Macro to sum the cells left of the current week number

  1. #1
    Registered User
    Join Date
    11-13-2012
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    77

    Macro to sum the cells left of the current week number

    Hi

    I would like a macro to insert a column to the left of a current week number and sum its values to the left from column E. For example the macro would select the week number based on current date (currently week20) and then insert a column to the left and sum its values from column E to the inserted column. Please see the attached spread sheet for more details.

    Any help would be greatly appreciated.

    Many Thanks
    Hoss
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Macro to sum the cells left of the current week number

    maybe something like:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-13-2012
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    77

    Re: Macro to sum the cells left of the current week number

    Dear ragulduy

    Thank you for your reply. When I run your macro the value of arrears is 53 and should be 62, i.e. it seems to only add up to week17, column U. Also sorry I should have pointed this out but my spreadsheet has about 100 rows of data therefore how can the results be autofilled to cover all the rows of data.

    Thanks
    Hoss

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to sum the cells left of the current week number

    I do not know why week-19 is 0 in your output, while it shows 9 in the input data.
    I also do not know where to insert a column. I have tested the code on 3 different days and it works. The output data is in A10. This can easily be changed once I know where to put the data in.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-13-2012
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    77

    Re: Macro to sum the cells left of the current week number

    Dear AB33

    you for your reply and sorry for taking this long to respond to your reply.

    Your macro works if quantiy for the selected week number is 0. For example if week number is 19 the output is 62 but it should return 53 (it includes qty 9 for week 19 where as it should add up from week 1 upto 18).

    The second request is that the macro does not work from week 1 to 9, could you please extend so that I can select output from week1. (week1 will return 0 arrears - week2, 1 arrears - week3, 9 arrears and so on).

    Lastly as my data covers about 100 rows is it possible to display output for all the rows as oppose to only row2?

    I tried to modify your code but did not understand it to make the above changes.

    Thanks
    Hoss

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to sum the cells left of the current week number

    Hoss,
    I have amended the code. The only bit left is the number of rows to copy.
    I do not know how comfortable you are to adjust this line of code.

    Please Login or Register  to view this content.
    Basically this line Rng.Row + 1
    copies row 2, so if you want to copy 100 rows, change this line. If it is too much hassle, I need to change the code.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-13-2012
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    77

    Re: Macro to sum the cells left of the current week number

    Dear AB33

    Thank you so much - it's exactly what I was looking for.

    Thanks again
    Hoss

+ 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. [SOLVED] Highlight current week number.
    By izy0502 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-07-2014, 09:45 AM
  2. Macro to sort an activity sheet by current week and current + last 1 and 2 weeks
    By engineering_excel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-13-2011, 11:28 AM
  3. getting the current week number formula
    By Kezwick in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-20-2011, 07:42 AM
  4. Replies: 4
    Last Post: 03-21-2011, 05:37 PM
  5. Week Number and current Hour
    By Macdave_19 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-10-2007, 09:37 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