+ Reply to Thread
Results 1 to 12 of 12

Using a foirmula, can I randomly add or subtract a number

  1. #1
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Using a foirmula, can I randomly add or subtract a number

    I am using the formula below, which works fine. I am wondering if there is a way I can have the formula randomly add or subtract 1 from the result. I don't want to have to decide if it's going to add or subtract, I want the formula (or VBA) to "decide" automatically.

    Please Login or Register  to view this content.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Using a foirmula, can I randomly add or subtract a number

    Hi Tom,

    This formula will return a one or negative one.

    =IF(RANDBETWEEN(0,1)=0,-1,1)

    Does that work with what you have?
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Using a foirmula, can I randomly add or subtract a number

    Hi,

    Perhaps

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Using a foirmula, can I randomly add or subtract a number

    My bad guys, I gave y'all misleading information. The add or subtract should be .001, not 1.

    Marvin.....Not quite what I was looking for, but, that formula will be useful to me for something else.

    Richard......I do believe you are on the right track, I just need it to add or subtract by .001 instead of 1 like I originally posted.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Using a foirmula, can I randomly add or subtract a number

    Quote Originally Posted by gmr4evr1 View Post

    Richard......I do believe you are on the right track, I just need it to add or subtract by .001 instead of 1 like I originally posted.
    In that case just modify to

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  6. #6
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Using a foirmula, can I randomly add or subtract a number

    Odd Anomolies.xlsx
    Dang it, you beat me too it. I kind-a figured that was all I needed to do, but I was testing it to be sure. Upon testing I found something strange happening. Odd anomalies and strange phenomenon.
    When I drag the formula in M1 down to M2, the values in column E change. If I drag the formula down to any row, then drag up to row 2, then back down again, I get a different "answer" in column N every time. I don't think this should be happening as both column E and M have the same exact formula and the formula is for columns C and D. I am cun-fuddled. I have attached the file.

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,169

    Re: Using a foirmula, can I randomly add or subtract a number

    This is because formulae in various columns use the RAND function which is volatile and changes when cells on the worksheet are changed (as per dragging dow
    Please Login or Register  to view this content.
    n a column).
    Last edited by JohnTopley; 11-01-2015 at 04:29 PM.

  8. #8
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Using a foirmula, can I randomly add or subtract a number

    Crud.....I didn't know that. That might defeat the entire purpose of what I was doing.. Thanks John, for the info.

  9. #9
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,718

    Re: Using a foirmula, can I randomly add or subtract a number

    Just put the RAND part of the formula in a single cell somewhere (which returns +0.001 or -0.001), then your formula could be:

    =IF(C3="","",AVERAGE(LEFT(C3,5),D3))+$X$1

    assuming X1 contains the RAND formula. Then you can copy this across and down as required.

    Hope this helps.

    Pete

  10. #10
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Using a foirmula, can I randomly add or subtract a number

    In my sample sheet that I posted above, I put this part of the RAND in R1
    Please Login or Register  to view this content.
    Then changed the formula in the other cells to
    Please Login or Register  to view this content.
    But now, whatever value is in R1 it adds or subtracts that value to all the cells in the column. Ex: R1 has a value of 0.001, the formula
    Please Login or Register  to view this content.
    Is in E3 through E17 and they all add 0.001.
    If R1 has -0.001, then they all subtract 0.001.
    What I want is for the cells in E to randomly add or subtract 0.001. Ex: E2, E3, E7 and E9 will add 0.001 while E4 through E6, E8 and E10 will subtract 0.001. Then, when the values in C3 and/or D3 change, the cells in E randomly add or subtract in a different order.

    Hopefully I didn't make that explanation confusing.

  11. #11
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,718

    Re: Using a foirmula, can I randomly add or subtract a number

    I think what you mean is that you want the random subtraction/addition, but for this NOT to change if other cells change.

    As RAND is volatile, I don't know how you can achieve that.

    Incidentally, the formula I gave you is slightly incorrect - it should be:

    =IF(C3="","",AVERAGE(LEFT(C3,5),D3)+$R$1)

    although this is not what you need.

    Hope this helps.

    Pete

  12. #12
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Using a foirmula, can I randomly add or subtract a number

    Right, when the cells in C and/or D change, I still want column E to do random subtraction/addition.
    I thank you all for your help and I will keep looking into this or an alternative method.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to divide a number randomly between cells
    By VelvetRain in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 11-24-2020, 05:38 AM
  2. Determine decimals in foirmula
    By Johnmus in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-25-2015, 06:05 PM
  3. Function inside a button to randomly generate number?
    By fkalinx in forum Excel General
    Replies: 2
    Last Post: 09-16-2014, 03:31 PM
  4. Replies: 3
    Last Post: 07-15-2014, 03:02 PM
  5. [SOLVED] counting number randomly
    By Exxcel Noob in forum Excel General
    Replies: 21
    Last Post: 06-09-2012, 06:35 PM
  6. Randomly Select Varying Number of Rows
    By Gos-C in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 08-24-2011, 09:15 AM
  7. Randomly selecting number from a list of numbers
    By buckhunt122 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-19-2011, 01:15 PM

Tags for this Thread

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