+ Reply to Thread
Results 1 to 47 of 47

Excel userform textboxes not updating, after change in MultiPage tab

  1. #1
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Excel userform textboxes not updating, after change in MultiPage tab

    I have this userform which takes selected cells and puts them in userform textboxes. Below the textboxes, there are command buttons which insert a character into the (1) the textbox, and (2) the relevant cell. The buttons are separated into MultiPage tabs, so far there are numbers and letters.
    * The change event where a different MultiPage tab is selected is causing problems. The update is made correctly to the cell but not the textbox (when additional characters are added).

    The way the code is structured is that when there is a change in MultiPage tab, the form setup code "FormID" is called up again because this fixes the overall height of the form ... as different tabs have a different height.


    Snapshot.png

    FORM CODE
    Please Login or Register  to view this content.
    CLASS MODULE clsDelegate
    Please Login or Register  to view this content.
    CLASS MODULE clsEvents
    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    You're probably missing the code TextBox change; there is no other event to update the contents.
    I'll see what I can find
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    First thing that comes to mind, is that you do nothing with the textbox and worksheet interaction.
    I just opened the file to see what it does, but you must interact with textbox AND the cell.
    Any change in the textbox must update the cell and vv, so if you press Backspace the character is deleted and then the textbox contents is pasted in the cell.
    Leading will have to be the textbox value
    Back to the drawingboard for the coding for you

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Why do you call all that code again if all you want to do is change the height?

  5. #5
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Any change in the textbox must update the cell and vv, so if you press Backspace the character is deleted and then the textbox contents is pasted in the cell.
    Leading will have to be the textbox value
    @Keebellah, there is a reason for this. It's because there is a variation in fonts, to my understanding this information can't be transferred between textbox to cell. If the textbox leads, I lose the fonts.
    I have heard about InkEdit Control but I get the feeling this was not the way to go.

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    If it's the font that you want to maintain then you will have to do that on the worksheet, a textbox does NOT interact with the worksheet font properties, it's plain text.
    You will have to account for that in the code when writing the textbox to the worksheet's cell

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    The code seems like an overkill to me, but then I haven't looked at what you are really trying to achieve, I agree with @rorya

  8. #8
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    I was just thinking that my logic in post #5 may not be correct. Not surprising.

    Why do you call all that code again if all you want to do is change the height?
    @rorya, I don't know how to do it otherwise.

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    I can't really make heads or tails how you did this.
    I spent half an hour trying to figure it out but lost it along the way.
    I'm not going to analyse your code to try to understand/decypher it, I'm missing parts, have no idea what the rest of your ideas are. and all the TBA buttons either; assumptions always sent me up the wrong path.
    Hope others can really help you.

  10. #10
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    That's OK. It may not be logical. I really use trial and error mostly.

  11. #11
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    That's my method too.
    Just a question.
    What is you're trying to achieve?
    Allow a user to edit each of the cells in B using the userform and only the buttons?

  12. #12
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    What is you're trying to achieve?
    I'm trying to add a character using the command buttons, at the cursor location, in the textbox. This works for me, except that when I change MultiPage tabs, the inserted characters are not shown in the textbox (it is written into the cell though, which it should be). If the tab is again changed, it does seem to refresh the textbox but I need this refreshed as the command button is pressed.

  13. #13
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    The reason is that when youchange the multipage you do not have the focus set to that textbox, and I don't know how you address is since you're using cls modules that invoke something but don't tell me the textbox's name.
    After you 'switch' multipage you have to either click that textbox first or check the code where you can reset the focus to that textbox again, then the text will show up in the textbox.

    You als don't have a backspace to clear a character from the textbox as well as from the cell.

  14. #14
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Yes I know but how to do in Visual Basic.

    With the delete character, I have something but not included here. I'm using "Cell.Characters(.SelStart, 1).Insert vbNullString".

  15. #15
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    I don't where that textbox comes from so I don't know either.
    I've checke the form but cannot detect it, you wrote (or copied) the code so you should know what the textboxs name (reference) is.

  16. #16
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    The text box name is "Text_Box_" & digit, as per code in the original post.

  17. #17
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Put the code that changes the heights into a separate routine and call it from both locations.

  18. #18
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Put the code that changes the heights into a separate routine and call it from both locations.
    No, this didn't resolve it

  19. #19
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Hard to comment further as I don't know what you actually did, but you should do that anyway. Your current approach is inefficient and doesn't really make sense.

  20. #20
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Please see attached.
    Attached Files Attached Files

  21. #21
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Try this version.

    I added code to FormID routine so it only create controls and event objects once.
    On further calls it only updates multipage and userform size.
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  22. #22
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    FWIW, you were still calling FormID from the multipage change event so it's not surprising it didn't fix it.

  23. #23
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    @Andy Pope. Thanks very much again. This works as intended.

  24. #24
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Thanks to others as well. The code may be jumbled up but I had a couple of other functionalities (not shown) which seemed to work with the way it was.

  25. #25
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Just a minor modification, instead of selecting the cell an pressing click, select the cell and right mouse button and position the userform accordingly too

  26. #26
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Ouch.
    The solution at post #21 creates controls and objects once. I had an extra part, not shown which was for a change in selected cells.
    It now won't work for this.
    Sorry about that.

    Please Login or Register  to view this content.

  27. #27
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Is there a way of capturing the name of the last visited text box?

  28. #28
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    That is what I was asking to be able to set the focus. with the code you're using?
    Maybe a global Variable to do that

  29. #29
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Maybe a global Variable to do that
    Yes I know. But how do you do it.

  30. #30
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel userform textboxes not updating, after change in MultiPage tab


  31. #31
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    This revision allow for selection of different ranges whilst the form is still loaded.

    It automatically resets the activecontrol to nothing when the selection changes.

    If you wanted to keep the activecontrol reference alive you would need to store the cell address as
    well and then you could compare address of activecontrol to all the newly referenced controls and set activecontrol if there was a match.
    Otherwise set reference to nothing and await user to select one of the textboxes.
    Attached Files Attached Files

  32. #32
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Are you really 'attached' to the way that userform has been coded?
    I would be surprised if it works in another way, given that there is a frame with textboxes and a MultiPage tab, and the requirement to update on the fly.

    Does it only apply to column B in the said worksheet?
    No there is nothing in the code which refers to Column B.

  33. #33
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Following from another post.

    This is my latest attempt to tell the code which is the active text box when there is a selection change in the MultiPage tab. The issue was that the change is not shown in the textbox when characters are added. Still not working though.

    Note that solution at post #31 would not update with a change in cell selection.

    MODIFIED CLASS MODULE clsEvents
    Please Login or Register  to view this content.
    CHANGES/ADDITIONS TO FORM CODE
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Un-Do Re-Do; 07-14-2018 at 12:24 PM.

  34. #34
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Is there a special reason you want the characters entered by pressing a button?
    What about a comma or a space no 'buttons' for that

  35. #35
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Is there a special reason you want the characters entered by pressing a button?
    I can't remember but there was a good reason, it may have something to do with rich text strings, ie, keeping fonts and sizes, etc.

    What about a comma or a space no 'buttons' for that
    You could use the ChrW function.
    Please Login or Register  to view this content.

  36. #36
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    I had this file ready for but pasted it in the wrong post
    Attached Files Attached Files

  37. #37
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Sorry but I'm not sure what your intention is.
    Can you please let someone try to solve my problem.

  38. #38
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,870

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Keebellah is trying to help solve your problem - have you looked at the sample file in post #36? If it's not what you want, just explain in what way it doesn't fit the bill.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  39. #39
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Hi AliGW and Keebellah. I have no intention of being difficult. I have had a look at the file and whilst it may be helpful to others, it is digressing from what I'm trying to do. I am appreciative of the response but I'm a bit under the pump ... so sorry to you Keebellah for the comment.

  40. #40
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,870

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Thanks for clarifying. Let's hope someone else understands what you require and can help. Please remember, though, that all help here is given voluntarily and for free, so we can't guarantee that it will be solved (if at all) within the timeframe you require. It may be that you need to redefine your issue at this point (don't start a new thread - give extra pertinent information here). The main reason for issues not being resolved is a lack of clarity on the part of the person asking for help, who of course fully understands what they want!

  41. #41
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    OK thank you, I'll bear this in mind.

  42. #42
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,870

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    So are you going to redefine the issue? I really feel, having read through this thread and the changes in requirements you have made along the way, that you need to do so if you want anyone to engage with this today.

  43. #43
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    I actually did start a new thread along similar bu not the same lines, so sorry if that is against forum rules. This was about 3 hours ago. I'll have a go at redefining the issue, give me 15 minutes to get everything together.

  44. #44
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    My last posted file does exactly what you want in a TextBox, I remove the Frame.
    But...
    Have fun with it, I'm unsubscribing from this post.

  45. #45
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,870

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    Duplicate threads are not allowed. Your second thread has now been closed. Please post the updated information here.

  46. #46
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    549

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    OK, so I'm not looking too good here.
    In trying to re-clarify the question, it turns out that the solution was given in post #31 by @Andy Pope. For some reason I had missed out on it.
    So apologies to you again Keeballah. Thanks for your time though. I hope I can make it up to you.
    Thanks to @Andy Pope for the solution, and AliGW for pushing it along.

  47. #47
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,870

    Re: Excel userform textboxes not updating, after change in MultiPage tab

    That's good to know - thanks for letting us know.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Userform with multipage, textboxes
    By wijnand in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-20-2016, 08:34 AM
  2. Change color for pages in multipage on userform
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-14-2015, 03:27 PM
  3. Initialising textboxes on a multipage userform
    By bigfatpies in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-30-2014, 05:21 PM
  4. [SOLVED] Change tab forecolor multipage UserForm
    By john55 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-24-2014, 06:08 AM
  5. [SOLVED] Change position of Multipage on userform
    By johnny_p in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-19-2014, 05:43 PM
  6. Help Populating Textboxes in Userform, With Multipage Userform.
    By mdmorgan24 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2012, 05:29 PM
  7. Userform Multipage Event Change
    By sepandb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-31-2008, 01:40 PM

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