Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-03-2018, 11:48 AM
piper7971 piper7971 is offline Rand and If Windows Vista Rand and If Office 2007
Advanced Beginner
Rand and If
 
Join Date: Jul 2010
Posts: 38
piper7971 is on a distinguished road
Default Rand and If

Happy New year to everyone!


I have a bit of a problem and I was hoping someone could help. The thing is that I am using a formula but I need to add a way that allows the result to be a number that is always either the same or less than the other.

I am using this formula in the cell H3
=IF($C$10=1,RANDBETWEEN(1,9),IF($C$10=2,RANDBETWEE N(10,99),IF($C$10=3,RANDBETWEEN(100,999),IF($C$10= 4,RANDBETWEEN(1000,9999),RANDBETWEEN(10000,99999)) )))

This formula generates a random number between the numbers in parenthesis according to the amount of digits selected in C10 which I want to do , but I also need a formula to put in cell J8 that does the same thing plus return any of those numbers either the same or less than the number in H3.

What I am trying to do is to create a worksheet with division problems so when I put that formula in H3 generates a number according to the amount of digits entered in C7 and to put a formula in J8 that does the same thing according to the amount of digits entered in C10 but that generates a number that is less than the one generated in H3. I have no idea as to how to do that.

In short, if I want a 3 digit number in H3 and it gives me a 318 and if I want a 2 digit number in J8 then the result should be any number but If I wanted to be a 3 digit number then it should give me a a 318 or any 3 digit number less or equal to 318


Any help would be greatly appreciated.
Liz
Reply With Quote
  #2  
Old 01-03-2018, 12:39 PM
NBVC's Avatar
NBVC NBVC is offline Rand and If Windows 10 Rand and If Office 2013
The Formula Guy
 
Join Date: Mar 2012
Location: Mississauga, CANADA
Posts: 215
NBVC will become famous soon enoughNBVC will become famous soon enough
Default

You can add a MIN() function around it so that it takes the Minimum of the RANDBETWEEN() result or the result in H3.

=MIN($H$3,IF($C$10=1,RANDBETWEEN(1,9),IF($C$10=2, RANDBETWEEN(10,99),IF($C$10=3,RANDBETWEEN(100,999) ,IF($C$10=4, RANDBETWEEN(1000,9999),RANDBETWEEN(10000,99999)))) ))
Reply With Quote
  #3  
Old 01-03-2018, 12:49 PM
NBVC's Avatar
NBVC NBVC is offline Rand and If Windows 10 Rand and If Office 2013
The Formula Guy
 
Join Date: Mar 2012
Location: Mississauga, CANADA
Posts: 215
NBVC will become famous soon enoughNBVC will become famous soon enough
Default

You can also shorten the formulas to:

=RANDBETWEEN(CHOOSE($C$10,1,10,100,1000),CHOOSE($C $10,9,99,999,9999))

and

=MIN($H$3,RANDBETWEEN(CHOOSE($C$10,1,10,100,1000), CHOOSE($C$10,9,99,999,9999)))
Reply With Quote
  #4  
Old 01-03-2018, 01:46 PM
piper7971 piper7971 is offline Rand and If Windows Vista Rand and If Office 2007
Advanced Beginner
Rand and If
 
Join Date: Jul 2010
Posts: 38
piper7971 is on a distinguished road
Default

That works but it occasionally gives me a divisor greater than the dividend resulting in a division that would total a percentage. is there a way that have the formula to always give me a divisor that is always less. This is an example of one of the returns it gave me.
1263 ÷ 2512 = 0.50
Reply With Quote
  #5  
Old 01-03-2018, 02:13 PM
NBVC's Avatar
NBVC NBVC is offline Rand and If Windows 10 Rand and If Office 2013
The Formula Guy
 
Join Date: Mar 2012
Location: Mississauga, CANADA
Posts: 215
NBVC will become famous soon enoughNBVC will become famous soon enough
Default

With the formulas I gave that should not be possible, unless you are not referencing the right cells. Please check the cell references in both formulas to ensure they are looking at the correct cells.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Rand and If +IF(RAND()........) confused newbie jeffk Excel 6 05-28-2013 08:03 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:31 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft