+ Reply to Thread
Results 1 to 7 of 7

Add cells including text

  1. #1
    Registered User
    Join Date
    08-06-2005
    Posts
    5

    Add cells including text

    Hi,

    I have a row of cells. as below:

    Hol 8.00 9.75 9.00 Hol 8.00 10 9.25 9.00 8.25

    I want to add the numerical elements in this row, but the text parts are causing an error. Is there a forumula that will only add the numerical parts, without resorting to nested IF statements saying IF(cell="Hol") etc etc?

    Thanks in advance

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    try

    =SUMIF(A1:J1,"<>Hol")

    for column A to J on row 1

    Quote Originally Posted by HappyTrucker
    Hi,

    I have a row of cells. as below:

    Hol 8.00 9.75 9.00 Hol 8.00 10 9.25 9.00 8.25

    I want to add the numerical elements in this row, but the text parts are causing an error. Is there a forumula that will only add the numerical parts, without resorting to nested IF statements saying IF(cell="Hol") etc etc?

    Thanks in advance

  3. #3
    Registered User
    Join Date
    08-06-2005
    Posts
    5
    Thanks for that. Looks like I headed down the right lines while waiting (can't stop trying can you?)

    I did forget that the Hol can be 2 types, Statutory or Compulsory Hol(s) or Hol(c). My fault.

    I've been tinkering and came up with this, based on the contents of the column headings DUTY and WTD(located over alternate columns) and the value of the Constants sheet (Duty or WTD), depending on which I'm summing.:

    Hol(s) 8.00 9.75 9.00 Hol(c) 0.00 10.00 9.25 9.00 8.25

    =SUMIF(B2:M2,Constants!F2,B3:M3)

    It seems to work too, which has surprised me most

    Thanks again, at least I know I was using the right formula.

  4. #4
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Thanks for the reply,

    also possible is

    =SUMIF(A1:J1,"<>Hol*")

    to cover both types.


    note, your formula tests row 2 and sums row 3, the recommended use of sumif (range to test, criteria, range to sum), mine is lazy and assumes the second range, however if you have consecutive rows of changing data be careful to check that the row format doesn't change and that the criteria is always in the same column for the tested and sum'd rows.


    Cheers

    Quote Originally Posted by HappyTrucker
    Thanks for that. Looks like I headed down the right lines while waiting (can't stop trying can you?)

    I did forget that the Hol can be 2 types, Statutory or Compulsory Hol(s) or Hol(c). My fault.

    I've been tinkering and came up with this, based on the contents of the column headings DUTY and WTD(located over alternate columns) and the value of the Constants sheet (Duty or WTD), depending on which I'm summing.:

    Hol(s) 8.00 9.75 9.00 Hol(c) 0.00 10.00 9.25 9.00 8.25

    =SUMIF(B2:M2,Constants!F2,B3:M3)

    It seems to work too, which has surprised me most

    Thanks again, at least I know I was using the right formula.
    Last edited by Bryan Hessey; 08-14-2005 at 08:45 AM.

  5. #5
    Bernard Liengme
    Guest

    Re: Add cells including text

    Why not =SUM(A1:J1) since SUM ignores text?
    --
    Bernard V Liengme
    www.stfx.ca/people/bliengme
    remove caps from email

    "HappyTrucker" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > Hi,
    >
    > I have a row of cells. as below:
    >
    > Hol 8.00 9.75 9.00 Hol 8.00 10 9.25 9.00 8.25
    >
    > I want to add the numerical elements in this row, but the text parts
    > are causing an error. Is there a forumula that will only add the
    > numerical parts, without resorting to nested IF statements saying
    > IF(cell="Hol") etc etc?
    >
    > Thanks in advance
    >
    >
    > --
    > HappyTrucker
    > ------------------------------------------------------------------------
    > HappyTrucker's Profile:
    > http://www.excelforum.com/member.php...o&userid=25997
    > View this thread: http://www.excelforum.com/showthread...hreadid=395644
    >





  6. #6
    Registered User
    Join Date
    08-06-2005
    Posts
    5
    Quote Originally Posted by Bernard Liengme
    Why not =SUM(A1:J1) since SUM ignores text?
    I can't use SUM unfortunately, because I needed to SUM alternate columns B3,D3,F3 and C3,E3,G3 etc), not the whole row.

  7. #7
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Hi,

    Not sure of your data, but if it is in the format of your second post,
    Hol(s) 8.00 9.75 9.00 Hol(c) 0.00 10.00 9.25 9.00 8.25
    then that can be totalled using (your data in A8 to J8)

    =IF(ISERROR(MATCH("Hol(c)",A8:J8,0)),SUM(A8:J8),SUM(A8: (OFFSET(A8,0,L8,1,1))))
    and in the next column
    =IF(ISERROR(MATCH("Hol(c)",A8:J8,0)),"",SUM((OFFSET(A8,0,L8,1,1) :J8)))

    with, in column L
    =MATCH("Hol(c)",A8:J8)-1

    the first column will total up all hols if no Hol(c) exists, or the hours to the left of that word.
    the second column will total any hours after finding Hol(c) or be blank.

    Also, a sum can be =Sum(B8,D8,F8,H8) etc.

    btw, well spotted Bernard, I read as far as "How do I sum excluding some columns" and should have read on.
    watch for spaces inserted to prevent smiley faces.


    Quote Originally Posted by HappyTrucker
    I can't use SUM unfortunately, because I needed to SUM alternate columns B3,D3,F3 and C3,E3,G3 etc), not the whole row.
    Last edited by Bryan Hessey; 08-14-2005 at 09:04 PM.

+ 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