+ Reply to Thread
Results 1 to 12 of 12

formula >0

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-09-2006
    Posts
    212

    formula >0

    Awesome site, thanks.
    I have 4 columns of numbers. Column 1 minus column 2 = answer(col3). Then I add column 4 to col 3.
    Sometimes the answer between col1 and col2 is a negative number. This will throw off everything. Is it possible to have excel subtract col2 from col1 or vice versa which ever way will always give a positive?

    25 32 col1-col2=-7
    I hope it can be;
    25 32 col1-col2=7 without having to change the forumla around or the columns. sometimmes I have over 1500 cells in a column and the way i do it nopw is go through manually and change it when i get negative.

    Cheers, looking forwRD to help.
    Martin.

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565
    Hi there,

    You'll have use an IF statement that checks if the answer is less than zero and if it is either change the formula around or multiply the result by minus one i.e.,

    If (col1 - col2 < 0, col2 - col1, col1 - col2) or
    If (col1 - col2 < 0, (col1 - col2)*-1, col1 - col2)

    HTH

    Robert

  3. #3
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    in col c use

    =MAX(A1-B1,B1-A1)
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Or, simply use the ABS function, which will give you the absolute value of any number.

    =ABS(A1-B1)

    You don't have to change every formula, either. You can easily update all of your formulas in a few clicks:

    Change the first formula in column C (say, C1) then double-click on the fill handle in the lower right corner of that cell and it will automatically fill that formula down as many rows as are in the preceding column (as long as there are no blank rows). Rather than double-clicking, you could also click on the fill handle and drag down as many rows as you need.
    Last edited by Paul; 03-22-2007 at 09:39 PM.

  5. #5
    Forum Contributor
    Join Date
    10-09-2006
    Posts
    212
    Thanks you guys, I will try all of them. I do like the ABS formula though, but will both of them return a positive result? and I dont mean just changing the negative to a positive. It know to must subtract one from the other or change it around to get the right positive result. (col1-col2) or (col2-col1).

    Kindest Regards,
    Martin.

  6. #6
    Forum Contributor
    Join Date
    10-09-2006
    Posts
    212
    I got the ABS to work, sweet. Thanks much. If I have a row of numbers like the following:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Is there a way I can get Exl to highlight the numbers in the row that could be ancored at say 3, then add 2. It would highlight 5, then add 2 highlight 7 add 2 highlight 9 etc.
    or if I start the sequence at 4 and add 6 it would highlight 10, then 16 then 22 then 28 then 34 etc.
    Is this possible?

    Kindest regards,
    Martin.

  7. #7
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by Martindelica
    I got the ABS to work, sweet. Thanks much. If I have a row of numbers like the following:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Is there a way I can get Exl to highlight the numbers in the row that could be ancored at say 3, then add 2. It would highlight 5, then add 2 highlight 7 add 2 highlight 9 etc.
    or if I start the sequence at 4 and add 6 it would highlight 10, then 16 then 22 then 28 then 34 etc.
    Is this possible?

    Kindest regards,
    Martin.
    Hi,

    select the column, Format, Conditional Format,
    formula is
    =IF(MOD((A1-4)/6,1)=0,TRUE)
    set the Pattern required.

    hth
    ---
    Si fractum non sit, noli id reficere.

+ 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