testingcode, you could limit the lines to this
However, OP wanted to include two time ranges.Code:ActiveCell.Value = TimeValue("06:30:00") + TimeSerial(0, Int((150 - 0 + 1) * Rnd + 0), 0)
Here's one way to do that
Having said that, since the original request was for a formula, this should sufficeCode:Randomize If Rnd > 0.5 Then ActiveCell.Value = (TimeValue("09:00:00") - TimeValue("06:30:00") + 0.0001) * Rnd + TimeValue("06:30:00") Else ActiveCell.Value = (TimeValue("14:00:00") - TimeValue("11:45:00") + 0.0001) * Rnd + TimeValue("11:45:00") End If
=IF(RAND()<0.5,TIME(6,RANDBETWEEN(30,180),0),TIME( 11,RANDBETWEEN(45,180),0))




Reply With Quote
Bookmarks