Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Aug 2010
    Location
    New Zealand
    Posts
    13
    Thanks
    11
    Thanked 1 Time in 1 Post

    Loading a UserForm from a spreadsheet

    Hi I want to load most of my userform from a spreadsheet before sending the data off to another sheet. I have about 15 textboxes to fill. Where exactly do I put the code to do this and is there an easy way to list all the boxes that need filling. They are all being filled from the same spreadsheet. Thank you for any assistance.

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    Use the Userform's Activate event and use code like:
    Code:
    With sheets("sheet name here")
    Me.Textbox1.text = .Range("A1").Value
    Me.Textbox2.text = .Range("B2").Value
    ' etc.
    It may be possible to simplify this if there is a pattern to where the data comes from and which textbox it goes to.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    New Lounger
    Join Date
    Aug 2010
    Location
    New Zealand
    Posts
    13
    Thanks
    11
    Thanked 1 Time in 1 Post
    Hi Rory, thanks for the reply. I eventually got it working by using the Userform initialize. I couldnt find where to put it so double clicked on the form and put it in there, replacing what was in there. I also had to change my userform hide to unload to trigger the initialize and the data loaded up fine. Does this sound ok? or should I change it to the activate event?

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    If you want to be able to hide and reshow and have the data clear each time, then use the Activate event, otherwise what you have is fine.
    Regards,
    Rory

    Microsoft MVP - Excel

  5. The Following User Says Thank You to rory For This Useful Post:

    motivated (2011-03-02)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •