Results 1 to 4 of 4

USING RANDOM FUNCTION Values

Threaded View

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

    USING RANDOM FUNCTION Values

    Hi All I am creating a table with the following headings

    Month
    Prod Code
    Item

    I am using a random function to fill in the details
    I want to fill in the item automatically in Item column based on the numbers generated in the prod.code column.

    My prod code generates number between 1 and 20 only.
    For example p002 in prod code the respective item column should show “Toyota”
    For example p003 in prod code the respective item column should show “Honda”
    For example p004 in prod code the respective item column should show “Volvo”

    My code is below. Where & when should i assign the item values to the product code


    Private Sub RAN_NUMB_Click()
    
    Dim RN1 As Long
    Dim RN2 As String
    Dim RN3 As Range
    Dim RN4 As Range
                
                
    RN2 = InputBox("ENTER YOUR CHOICE" & vbNewLine _
                & "1.Months" & vbNewLine _
                & "2.Product Code" & vbNewLine _
                & "3.No of Items" & vbNewLine _
                & "4.Sales")
                
    
    Select Case RN2
    
    Case 1                                               'Months
    
    For Each RN3 In Range("b2:b15")
    
    RN3.Value = MonthName(Int((10 - 1 + 1) * Rnd + 1), True)
    
    Next
    
    
    Case 2                                                  'product Codes
    
    For Each RN3 In Range("c2:C15")
    RN3.Value = "PC00" & (Int((20 - 1 + 1) * Rnd + 1))
    Next RN3
    
     
    End Select
    
    
    End Sub
    Last edited by grkchakri; 12-21-2013 at 03:30 AM.
    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. random numbers between set values
    By thickmart in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-10-2013, 07:24 AM
  2. VBA Creating Expandable Random Values Based on Values on a different Sheet
    By richter394 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-02-2013, 03:14 PM
  3. Replies: 3
    Last Post: 09-30-2012, 03:03 PM
  4. Mutiple values to replace with multiple values random in fields
    By CatalinNic in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-18-2011, 01:52 PM
  5. Function to match random list values to set list values.
    By Sandman4432 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-24-2007, 09:22 PM

Tags for this Thread

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