Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Option Explicit
Sub Randomish()
Dim xMin As Double
Dim xActual As Double
Dim xTarget As Double
Dim i As Long
Sheets("Sheet2").Activate
xTarget = Range("B1")
xMin = 100000000
Application.ScreenUpdating = False
For i = 1 To 100
Range("B6:F105").Formula = "=(RANDBETWEEN($B$3,$B$4)+(RANDBETWEEN(0,9)/100))"
Range("B6:F105").Copy
Range("B6:F105").PasteSpecial xlPasteValues
xActual = Range("H1")
If Abs(xTarget - xActual) / xTarget < 0.01 Then
MsgBox ("Run complete - difference is " & Format(Abs(xTarget - xActual) / xTarget, "0.00%"))
Exit Sub
End If
If Abs(xTarget - xActual) < xMin Then xMin = Abs(xTarget - xActual)
Next
MsgBox ("Sorry - couldn't get within reach. Closest was " & Format(xMin / xTarget, "0.00%") & ". Please try again.")
Application.ScreenUpdating = True
End Sub
Regards,If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
Lookup - Vlookup | 9 | 49 | |
Modification to nested formula needed | 2 | 25 | |
Modify Array formula - Reduce Calculation Time | 4 | 31 | |
Tricky Shapes formula | 3 | 18 |
Join the community of 500,000 technology professionals and ask your questions.