+ Reply to Thread
Results 1 to 6 of 6

manipulate userform from excel sheet

  1. #1
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    manipulate userform from excel sheet

    Hi,
    i'm having some userfrom issues.
    I have a workbook with a simple code that opens a userform and populates the textbox with the word "Hi".
    The issue is that the first time the code is run it won't display anything, the second time it will display "Hi".
    If i then enter the code and change "hi" to (say) "Bye", so when i run the code again the useform will show "Hi" and only the 2nd time around will it display "Bye".
    It's as if the code stores information internally, which i did not know!.
    Here's the code:
    Please Login or Register  to view this content.
    (for some reason i am having trouble uploading a workbook so i hope this is enough information)
    Any help on this would be greatly appreciated.

  2. #2
    Forum Expert
    Join Date
    09-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    2,278

    Re: manipulate userform from excel sheet

    Hello
    On the User Form 'Initialize' Event put the code:

    Please Login or Register  to view this content.
    When the form is opened it should show the text string assigned to Text Box 1.

    Alterntatively, swap the code around:

    Please Login or Register  to view this content.
    DBY
    Last edited by DBY; 03-22-2016 at 04:03 PM.

  3. #3
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: manipulate userform from excel sheet

    Quote Originally Posted by DBY View Post
    Hello
    On the User Form 'Initialize' Event put the code:

    Please Login or Register  to view this content.
    When the form is opened it should show the text string assigned to Text Box 1.

    DBY
    Thanks.
    Problem is that when i open the userform manually i don't want the textbox to be filled, i only want it filled when i call the userform from a button on a sheet.

  4. #4
    Forum Expert
    Join Date
    09-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    2,278

    Re: manipulate userform from excel sheet

    Perhaps you didn't see my edit, you can amend the order of the code on your button click:

    Please Login or Register  to view this content.
    the text box value is then assigned before the form is opened from the button click, I should have put this solution first, sorry.

  5. #5
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: manipulate userform from excel sheet

    Thanks DBY,
    And you're right, i responded to you before you did the edit.
    Btw, i have no idea why the code was acting funny and why your idea resolved it? Can you briefly explain it to me?

  6. #6
    Forum Expert
    Join Date
    09-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    2,278

    Re: manipulate userform from excel sheet

    Glad it's resolved. To be honest, I'm not an expert in VBA and I'm not sure why but it seems any object values have to be applied before the form is initialized as the code stops when the form opens. A second trigger seems necessary to insert the text box value from memory. If any VBA experts here can explain the logic I too would be interested to know.

    Thanks for the Rep mark.

+ 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. Manipulate data from 1 sheet based on another sheet (tab)
    By fa355115 in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 10-01-2015, 02:06 PM
  2. class modules to return/manipulate sheet data?
    By bsapaka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-03-2014, 12:46 PM
  3. Populate Excel Userform with Sheet names with double click to open the sheet ??
    By Shacker in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-08-2013, 03:54 PM
  4. [SOLVED] EXCEL USERFORM- pull data from sheet 1 into userform
    By PANTECH in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-18-2013, 11:10 AM
  5. [SOLVED] Manipulate and transpose data to another sheet via a Macro
    By Phil_MacRae in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-12-2012, 02:22 PM
  6. How to manipulate Sheet function
    By sadhammer in forum Excel General
    Replies: 4
    Last Post: 06-15-2012, 03:04 AM
  7. Replies: 1
    Last Post: 06-24-2010, 09:39 PM

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