+ Reply to Thread
Results 1 to 4 of 4

Userform Textbox Behaviour

  1. #1
    Registered User
    Join Date
    07-27-2010
    Location
    Kent, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Userform Textbox Behaviour

    Hi all,

    This is my first post, but I've been helped 100's of times by the site!

    Right, I've got a userform I'm using as a control panel, it comes up automatically when the workbook opens. I've put a bunch of buttons on their which are cool, and I've got pretty much everything I want on there working fine, staying visible at all times.

    I had put a little text box just saying 'Welcome' in the body of the userform, but I've been asked whether I can change that into a kind of message centre depending on what worksheet tab is open.

    For example, if Sheet 1 is open, the text on the control panel says 'Here's some help for Sheet 1', if the user then clicks to open Sheet 2 the text changes to say 'Here's some help for Sheet 2'. Is there any coding I can use to change the text depending on what tab is open? I was thinking some kind of ActiveWorksheet tab or something? But all the ones I've tried to create on my own fail!

    The only way I can think of doing it is duplicating my whole userform over and over and then having, effectively, a different userform opening on each worksheet tab. But that would take me forever to copy all the button codes and design of the form itself... Is there an easier way????

    Thanks for any help in advance...

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: Userform Textbox Behaviour

    You basically need
    Please Login or Register  to view this content.
    How you apply that would depend on whether the form is modal (simple - just use the Initialize or Activate event) or modeless (trickier as you need to trap the user switching sheets while the form is open).
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,228

    Re: Userform Textbox Behaviour

    Put the following code behind each worksheet and simply change the text message.

    Private Sub Worksheet_Activate()
    UserForm1.TextBox1.Text = "This is Sheet number 2!!"
    End Sub

    When the worksheet is activates the text on your userform will change.

  4. #4
    Registered User
    Join Date
    07-27-2010
    Location
    Kent, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Userform Textbox Behaviour

    Wow...A complete solution within 30mins!!
    Thanks guys, works perfectly!!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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