+ Reply to Thread
Results 1 to 3 of 3

UserForm Code Question/Help

  1. #1
    Forum Contributor
    Join Date
    12-16-2005
    Posts
    161

    UserForm Code Question/Help

    I have a worksheet with 5 commandbuttons. Each commndbutton opens the same userform. There is a single textbox and an 'enter' commandbutton on the userform.

    When the userform is openend using commandbutton1, I want data from textbox1 to be placed in say cell A1 when the userform 'enter' button is clicked.

    When the userform is opened using commandbutton2, I want data from textbox2 to be placed is say cell B1 when the userform 'enter' button is clicked.

    Would appreciate any assistance/examples on how to code this.

    Cheers

    Peter

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612
    I don't quite understand, i.e., you say the userform has ONE textbox, and ONE Enter button; but, then you say you want data from textbox1 or textbox2...entered on the sheet.

    However, you could declare a global variable, say, BtnNum. Then, in the five button click events that call the userform, you could set BtnNum to the number of that particular button before calling the userform.

    The code for the Enter button click event would use a SELECT CASE BtnNum routine to check the value of BtnNum and select the appropriate activecell into which the data would be copied.
    Ben Van Johnson

  3. #3
    Forum Contributor
    Join Date
    12-16-2005
    Posts
    161
    Thanks for your help Proton

+ 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