Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'works for file: https://1drv.ms/x/s!AiO7_3PtXmZ9gqdSf7C4NOtWDPdfeg?e=Mrz62E
- 'LinkedIN Article: https://www.linkedin.com/pulse/how-much-benefit-does-excels-new-let-function-offer-steven-rider
- Sub MakeResults()
- Const theLoopsToDo As Long = 8
- Call TestPasteFormula(True, theLoopsToDo)
- Call TestPasteFormula(False, theLoopsToDo)
- End Sub
- Private Sub TestPasteFormula(isLet As Boolean, LoopsToPerformRecalc As Long)
- Const theColumnForLet As Long = 6
- Const IncludePasteTime As Boolean = False
- Dim ws As Worksheet, RLine As Long, theColoumn As Long
- Set ws = ActiveSheet
- With ws
- .Range("A:C").ClearContents
- DoEvents
- theColoumn = IIf(isLet, theColumnForLet, theColumnForLet + 1)
- Dim trackTime As Double
- .Cells(1, theColoumn).Copy
- If IncludePasteTime = True Then trackTime = Now
- .Range("C:C").PasteSpecial xlPasteFormulas
- Call GenerateNewNumbers
- DoEvents
- Dim b As Byte
- If trackTime = 0 Then trackTime = Now
- For b = 1 To LoopsToPerformRecalc
- Call GenerateNewNumbers
- DoEvents
- Next
- trackTime = Round((Now - trackTime) * 24 * 3600, 0)
- RLine = .Cells(Rows.Count, theColoumn).End(xlUp).Row + 1
- .Cells(RLine, theColoumn).Value = trackTime
- If isLet Then .Cells(RLine, theColoumn + 2).Value = LoopsToPerformRecalc
- End With
- End Sub
- Private Sub GenerateNewNumbers()
- Dim aVrt(), ws As Worksheet, x As Long, y As Long
- Set ws = ActiveSheet
- ws.Range("A:B").ClearContents
- aVrt = ws.Range("A:B")
- For y = LBound(aVrt, 2) To UBound(aVrt, 2)
- For x = LBound(aVrt) To UBound(aVrt)
- aVrt(x, y) = VBA.Rnd() * 6120 Mod 8 + 1
- Next x
- Next y
- ws.Range("A:B") = aVrt
- DoEvents
- End Sub
Add Comment
Please, Sign In to add comment