Hi All
I am creating command button to generate numbers from Range("B2 : G26"). The code works well with the active sheet.
I am looking for suggestions on how to generate numbers in other sheets for range ("B2:G26") as well using the same code/ command button.
Dim ab1 As Range
Dim AB2 As Worksheet
Dim xy As Integer
For Each ab1 In Range("b2:g26")
ab1.Offset(0, 0).Value = Application.WorksheetFunction.RandBetween(5, 99)
Next ab1
'Is there is something that i can write here using offset/ index function to apply in the second and third sheets
Also i would like while the below line code executes only one set of numbers (example :10 across the range)
Private Sub CommandButton2_Click()
Dim AB3 As Worksheet
Set AB3 = Worksheets("FEB")
AB3.Range("B2:G26").Offset(0, 0) = Application.WorksheetFunction.RandBetween(5, 99)
End Sub
Bookmarks