Solved

extract data from listbox on userform

Posted on 2014-07-28
5
892 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 

Author Comment

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

Accepted Solution

by:
Rob Henson earned 300 total points
ID: 40226483
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
ID: 40226530
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
ID: 40226640
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
ID: 40226659
My mistake. Changed .rowsource to .value and now works fine! Thank you very much!
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

726 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