+ Reply to Thread
Results 1 to 4 of 4

Linking Cell Text to a Command Button

Hybrid View

  1. #1
    Registered User
    Join Date
    03-04-2005
    Posts
    12

    Linking Cell Text to a Command Button

    Hello,

    I work in a product qualification enviroment where I would like to be able to have a user put in various part numbers in cells and then the command buttons that I have already created would take on those names and perform the task that I have already programmed. Is this even possible? So basically I just want to call the text from a cell and have it be the text on my command buttons.

    Thanks in advance

  2. #2
    Registered User
    Join Date
    06-21-2004
    Location
    Phoenix, Az
    Posts
    30
    -Add an OLE command button:
    (view->toolbars->control toolbox)

    -right click the button ->properties, give the button the name: cmdButton
    -ALT + F11 brings you to the VB editor,
    -select the sheet where the button resides
    -select the Worksheet Change event
    -enter the following code:

    Private Sub Worksheet_Change(ByVal Target As Range)

    cmdButton.Caption = Target.Value

    End Sub

    ' optionally you can add an if statement to validate target.column, target.row etc

  3. #3
    Registered User
    Join Date
    03-04-2005
    Posts
    12
    okay, I am still a little confused on this. I have entered the following where my worksheet name is "cover" and my cmdbutton name is CommandButton1. I want to link the cell "D45" on sheet "Tool Data" to the button on sheet "Cover". I guess mostly I don't understand what goes in the Target and Range space as each time I try and put something in those spots the text turns red and I get an error.

    Private Sub Worksheet_Change(ByVal Target As Range)

    CommandButton1.Caption = Target

    End Sub

    Thanks,
    Baxter

  4. #4
    Registered User
    Join Date
    03-04-2005
    Posts
    12
    By the way, something strange is happening with the above code just as it is. I have also created a list from Data->Validation menus. When I do this, my command button takes on the value of the value selected from the list and changes dynamically when I choose a different value from my drop down list. I however can't seem to get it to do what I want and that is to take the value of a certain cell and plug that in as the text for my command button.

    Thanks in advance for your help

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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