Results 1 to 5 of 5

How to link codes for two command buttons

Threaded View

  1. #1
    Registered User
    Join Date
    04-24-2014
    Location
    Swindon
    MS-Off Ver
    Excel 2010
    Posts
    2

    How to link codes for two command buttons

    I have created a form and has two command buttons, Say A and B.

    Command button A uses random number generator to select a cell from a range in the spread sheet which is then used in vlookup function to return a value from column number 2 of a record in text box1.

    I would like the Command button B to return the value from column number 3 for the same record in text box2.

    Kindly advise how can I do it.

    The code for Command button A looks like:

    Private Sub CommandButton3_Click()

    Dim LRandomNumber As Integer
    Dim Meaning As String
    Dim Word As String

    LRandomNumber = Int((50 - 1 + 1) * Rnd + 1)

    TextBox1.Value = Application.WorksheetFunction.VLookup(LRandomNumber, Sheet1.Range("A1:B51"), 2, True)

    End Sub
    Last edited by sg2808; 04-24-2014 at 10:25 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 02-05-2014, 12:34 AM
  2. Useform Code - 12 Command Buttons dependant on other command buttons
    By darrenkaye in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-20-2013, 10:58 AM
  3. Master Command Button to call on other Command Buttons located in other Workbooks
    By MrNickRegan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-05-2013, 07:57 PM
  4. Code for a master command button to change the backcolor of multiple command buttons?
    By panttherm5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2012, 10:11 PM
  5. [SOLVED] Change listbox link cell with command buttons
    By zplugger in forum Excel General
    Replies: 1
    Last Post: 08-12-2012, 06:43 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