Solved

extract data from listbox on userform

Posted on 2014-07-28
5
844 Views
Last Modified: 2014-07-29
Hi: I have an excel 2007 worksheet, comprising jobs in progress.  On the form I have a userform with a list box. THe listbox lists the job numbers and names . I want to be able to select a job from the list and by doing so populate a series of textboxes  on the form with other  data for that job, drawn from the worksheet. For example select job 123 and the cost for that job fills textbox1, date fills textbox2, etc. A bit like HLOOKUP for a userform! . I have read about offset but this does not seem to do the 'job'. Does anybody know how to set up the form to read in the data?
Thanks!
0
Comment
Question by:ClaytonGlass
  • 4
5 Comments
 

Author Comment

by:ClaytonGlass
Comment Utility
Hi: just to follow up I attach a mockup of the worksheet. Hope it helps!
userformlistbox.xlsm
0
 
LVL 31

Accepted Solution

by:
Rob Henson earned 300 total points
Comment Utility
You can link your input and text boxes on the user form to cells on a worksheet. By doing so you can set the value of the input to a cell and then have other cells with lookups as suggested pulling the other required data. These cells are then referred to by the boxes on the User Form and should update as the input changes.

With the input box you will have to set a small piece of VBA to populate the relevant cell and maybe force calculation if it is switched off.

Thanks
Rob h
0
 

Author Comment

by:ClaytonGlass
Comment Utility
Aaahhhhh... you mean use the list box to populate a spare cell on the worksheet (say at the very bottom). THen using actual hloookup formula on worksheet to populate adjacent cells on the spreadsheet from that selection. Then the userform picks up the contents of the adjacent lookup cells.
 So data loops from worksheet to userform, back to worksheet, then back to userform? Sounds like a plan!
Let me give it a go. Thanks so far!
0
 

Author Comment

by:ClaytonGlass
Comment Utility
OK - here is the code I put onto a button on the userform:

Sheets("Job list").Range("A501").Value = Me.Controls("TextBox1").Text
TextBox2.RowSource = Sheets("Job list").Range("B501").Value

On the sheet cell B501 is a VLOOKUP of the adjacent cell in the range for the job selected in the list. A501 works, B501 reads the lookup, but the data does not return to textbox2 on the form.
Error "could not set RowSource Property. Member not found". Do you know what this is - and how to resolve?
Thanks!
0
 

Author Closing Comment

by:ClaytonGlass
Comment Utility
My mistake. Changed .rowsource to .value and now works fine! Thank you very much!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now