+ Reply to Thread
Results 1 to 7 of 7

If a cell has a similar value to the one above it, total adjacent columns

  1. #1
    Registered User
    Join Date
    09-29-2007
    Posts
    8

    If a cell has a similar value to the one above it, total adjacent columns

    Hi One and All,

    I would normally ask for help from a colleague but as its a saturday he isn't around and I would like to get this to work today if at all possible.

    Here's what I am after trying to achieve:

    If a cell has a date in it that is the same as a cell above, I would like to total time values in cells that are adjacent to these original cells. Maybe the example below explains it better.

    A1 A2 A3
    01/01/09 1:00
    01/01/09 3:00 4:00
    02/01/09 0:10 0:10
    03/01/09 0:50
    03/01/09 0:50 1:40
    Last edited by scottdernie@aol; 12-05-2009 at 10:09 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: If a cell has a similar value to the one above it, total adjacent columns

    By A1:A3 I presume you mean A1:C1 ?

    If so, formula in C1 (first possible result)

    =IF($A2=$A1,"",SUMIF($A$1:$A1,$A1,$B$1:$B1))
    copied down for all rows
    (format cells as Time - perhaps to [hh]:mm - not clear as to your preference)

  3. #3
    Registered User
    Join Date
    09-29-2007
    Posts
    8

    Re: If a cell has a similar value to the one above it, total adjacent columns

    Wow thanks for the quick response.

    You are correct about the cell references!

    I have pasted the formula into C1 and copied down as you have instructed, however when it does give a value they are all 0:00.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: If a cell has a similar value to the one above it, total adjacent columns

    Implication then being that the values are times stored as text...

    either

    a) highlight column B -> run Data -> Text to Columns -> click Finish

    b) use a more expensive formula in column C

    C1: =IF($A2=$A1,"",SUMPRODUCT(($A$1:$A1=$A1)*$B$1:$B1))
    copied down

    If the above don't work then encase $B$1:$B1 within TRIM and try again... if that doesn't work we'll want to see an example ... (probably a CHAR(160) error or somesuch)

  5. #5
    Registered User
    Join Date
    09-29-2007
    Posts
    8

    Re: If a cell has a similar value to the one above it, total adjacent columns

    It looks as my times are entered as text and not as times as they have been imported from an access database.
    I have tried to change the format to [h]:mm but this does not work, is there anything I can do other than change the source data?

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: If a cell has a similar value to the one above it, total adjacent columns

    ...is there anything I can do other than change the source data?
    Have you tried the SUMPRODUCT as suggested ?

    I have tried to change the format to [h]:mm but this does not work
    Changing the format of a cell does not alter the underlying data type of the value already within it... eg A1: Apple... formatting A1 as Number does not in turn convert Apple into a number - the same is true of any string including "number strings"

  7. #7
    Registered User
    Join Date
    09-29-2007
    Posts
    8

    Smile Re: If a cell has a similar value to the one above it, total adjacent columns

    DonkeyOte thank you ever so much, I'd worked out it was due to the times being entered as text but you beat me to the solution.

    Both of the ones you suggested worked just fine. Thanks again

+ 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