Consulting

Results 1 to 4 of 4

Thread: Solved: Excel 2003 - Need to sum numbers that are in cells formated as text

  1. #1
    VBAX Expert
    Joined
    Sep 2010
    Posts
    604
    Location

    Solved: Excel 2003 - Need to sum numbers that are in cells formated as text

    I'm using the code shown below to give a sum total in Cell P18 by adding the number value in Cell i18 to Cell P18

    It works fine as long as both cells are formatted as a number or general, but if the cells accidentally become formatted as text the result is concatenation instead of summing.

    Is there an alternative command that will sum the two numbers regardless of the cell formatting?
    [vba]Range("P18").Value = Range("P18").Value + Range("I18").Value[/vba]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Range("P18").Value = Val(Range("P18").Value) + Val(Range("I18").Value)
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Expert
    Joined
    Sep 2010
    Posts
    604
    Location
    Thanks once again xld. -- Without you and the other great experts at this forum I'd never be able to get a project completed and bug free before the "frustration" and "taking too long" factor's would overwhelm me.

    In other words instead of me being like this ->
    --> you enable me to be at -> and finding some enjoyment with the task, as well as getting enough rest.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    That's the whole aim Frank, to help you along the road we previously travelled
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •