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)))) ))
|