+ Reply to Thread
Results 1 to 10 of 10

Userform Textbox and Label change from cell

  1. #1
    Registered User
    Join Date
    03-02-2008
    Posts
    42

    Userform Textbox and Label change from cell

    Hi,

    I want a floating userform (showmodel = false) to display the results of a cell.

    On excell spreadsheet I can assign a cell value to an object/shape, as the cell value changes so does the display on the object automatically.

    I want the same results on a userform.

    I tried the texbox & using the the controlsource from the properties window, this was only good for one result. for the next result the textbox won't change its value.

    As i want this for display purpose only can i use the label for the above problem

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    If you have a userform as you describe and the controlsource of the textbox set to say A1, then every time A1 changes the TextBox should change.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    03-02-2008
    Posts
    42
    Quote Originally Posted by royUK
    If you have a userform as you describe and the controlsource of the textbox set to say A1, then every time A1 changes the TextBox should change.

    I have attached a simple userform below.

    textbox.zip

    I have an autofilter on a coulmn and a sub calculation on cell A2. cell A3 = A2. the texbox is set to A3.

    When the userform is open and I set the eqation on A3 (A3=A2) the textbox number changes but when i close and open again the number stays static.

    can someone help please thanks

    Thanks

    PS instead of a textbox can I use the label to do the same thing?
    Last edited by Panic; 04-20-2008 at 01:33 AM.

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I don't know what you are expecting but the textbox changes every tim ethe linked cell changes. I also can't see why you don't link to A2.

  6. #6
    Registered User
    Join Date
    03-02-2008
    Posts
    42
    I am new at VBA, so please bare with me.

    This is what I am doing:
    1) I click the userform button to open the userform
    2) I use the autofilter to filter numbers, and all works fine, numbers change on cell and userform textbox.
    3) I press X on the userform to close
    4) I press the userform button to bring the Userform back to the screen
    5) Now when I use the autofilter the Textbox numbers do not change. A3 also does not change.

    Thats the problem I am having, it seems like the userform disables my equation on A3 (thats the reason its not on A2, others the whole subtotal equation gets deleted and replaced with the actual number)

    Is it something that i am doing wrong or have i not set things properly.

    Please help (even if i am a total novice!!!)

    Thanks

    Panic

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    That's because the Controlsource works both ways, the cell's contents are overwritten by the textbox value, so your formula is lost

  8. #8
    Registered User
    Join Date
    03-02-2008
    Posts
    42
    Can i have something that will only display the cell contents?

    thanks

    Panic

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Panic,

    I have included the modifications shown here in the attached workbook. I removed the control cell link in TextBox1. A worksheet event macro now updates the the TextBox1. The text box is also updated automatically whenever the UserForm is Activated.

    UserForm code
    Please Login or Register  to view this content.
    [b]Sheet1 Event Code[/code]
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    03-02-2008
    Posts
    42
    Hi Leith,

    Thanks for the above!!!

    This works perfectly, much appreciated!!

    Panic

+ 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