-
Hi Yasser,
Try to avoid looping, it slows down your code
[VBA]
Sub Test()
Dim rng1, cell, R1, R2 As Range
Dim cel As Range
Set cel = Selection
Set R1 = ActiveSheet.Range("B1")
Set R2 = ActiveSheet.Range("B2")
Set R3 = ActiveSheet.Range("B3")
Set rng1 = Range(Cells(1, "C"), Cells(R3, "C"))
Application.ScreenUpdating = False
Columns("C:C").ClearContents
With rng1
.Formula = "=Randbetween(" & R1 & "," & R2 & ")"
.Copy
.PasteSpecial Paste:=xlPasteValues
End With
cel.Select
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules