+ Reply to Thread
Results 1 to 7 of 7

sum data depending on the month

  1. #1
    Registered User
    Join Date
    08-29-2012
    Location
    Amman
    MS-Off Ver
    Excel 2007
    Posts
    36

    sum data depending on the month

    hi
    column E is a date column with some blank cells too
    I want to sum the values in column I only if the month in column E in the same row is august or before
    and return the result to the cell "I7616"
    I am new to this ... I tried this code but I don't know what is wrong with it
    the editor highlights the if statment line ...

    can you help me ??


    Please Login or Register  to view this content.

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: sum data depending on the month

    Seems you should just use a formula for this

    =SUMPRODUCT(--(MONTH(E1:E7614)<=8)*(E1:E7614<>"")*(I1:I7614))
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Registered User
    Join Date
    08-29-2012
    Location
    Amman
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: sum data depending on the month

    thanks for help but I want to return the value to textbox too and use it in other calculation on my program and the month august will be changed according to a combobox selection ... thats why am using vba

  4. #4
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: sum data depending on the month

    I don't get any errors when running your code, though I only tested it on a limited range of rows.
    However, if the month is changing per a combobox selection, then you need to define a variable for this and replace the hard-coded "8" with the variable.

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

    Re: sum data depending on the month

    I think the error is most likely in this part of the If statement

    Month(Cells(i, "E").Value) <= 8 Then.

    My guess is you need to put the date in the right format

  6. #6
    Registered User
    Join Date
    08-29-2012
    Location
    Amman
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: sum data depending on the month

    thanks everybody ... it was useful and I solved the problem

  7. #7
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: sum data depending on the month

    Please tell the forum how you solved it so that others who face a similar issue will have an answer.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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