Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

extract data from listbox on userform

Posted on 2014-07-28
5
Medium Priority
?
987 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
ID: 40226105
Hi: just to follow up I attach a mockup of the worksheet. Hope it helps!
userformlistbox.xlsm
0
 
LVL 34

Accepted Solution

by:
Rob Henson earned 1200 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

971 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