I'm a very inexperienced VBA user, I've just created my first "For Each" loop but it's very slow. I'm happy that it works but eager to know if there is a alternative method that is quicker. Any advice would be appreciated but please bear in mind my inexperience!
My routine takes two variables "UserSelectionMin" and "UserSelectionMax" and uses them in conjunction with the RandBetween function to place a value in every blank (or zero) cell in the selected range. This is the loop:
Dim addr As String
addr = Selection.Address
For Each c In Worksheets("matches").Range(addr).Cells
If Abs(c.Value) = 0 Then c.Value = WorksheetFunction.RandBetween(UserSelectionMin, UserSelectionMax)
Next
Any advice on speeding this up would be great. I'm enjoying learning new things but the curve is steep! Thanks in advance from a newbie.
Mark
Aucun commentaire:
Enregistrer un commentaire