Results 1 to 4 of 4

Generate Random numbers across sheets

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-12-2011
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    263

    Generate Random numbers across sheets

    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
    Last edited by grkchakri; 04-17-2018 at 02:54 PM.
    Never confuse a single defeat to the final defeat.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] generate random numbers between 1 to 10 vba rnd()
    By ihrktho in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-09-2014, 09:51 AM
  2. Generate Random Numbers Between 0-9
    By dreicer_Jarr in forum Excel General
    Replies: 11
    Last Post: 01-17-2014, 01:00 AM
  3. [SOLVED] Generate Random numbers where sum = 1
    By sajeel in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-18-2013, 07:12 AM
  4. [SOLVED] Generate Random Numbers
    By stojko89 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-09-2013, 02:49 AM
  5. generate random numbers
    By fo05kka in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-08-2009, 09:55 PM
  6. Using VBA to generate random numbers
    By matt3542 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-02-2008, 09:15 AM
  7. Generate Random Numbers
    By Rgaherty in forum Excel General
    Replies: 5
    Last Post: 10-30-2007, 04:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1