Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Combobox selection

Hi All,
I am hoping for help with a bit of code, I want to use a combobox on a
userform to be used as a selector for parts. The spreadsheet is called
"Stock" It looks for the stock number is column A and I would like it to
show the name of the part in a textbox. I have the basic code to fill the
combobox but I am not sure how to use the selection using the
combobox.change method?
i.e.

PartNumber (combobox) Item Desc Textbox

1231 USB Cable

Thanks in Advance
Greg


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Combobox selection

Greg B presented the following explanation :
Hi All,
I am hoping for help with a bit of code, I want to use a combobox on a
userform to be used as a selector for parts. The spreadsheet is called
"Stock" It looks for the stock number is column A and I would like it to show
the name of the part in a textbox. I have the basic code to fill the combobox
but I am not sure how to use the selection using the combobox.change method?
i.e.

PartNumber (combobox) Item Desc Textbox

1231 USB Cable

Thanks in Advance
Greg


You could use a label for the description, unless you want users to be
able to edit the description.

You can put all the part data into the combobox using the appropriate
'ColumnCount' so it contains the same values as your spreadsheet. Then
your textbox can hold the column that contains the description of the
selected item. You can hide any columns you don't want displayed by
setting 'ColumnWidths' so those columns are zero width. Also, you can
set the 'BoundColumn' to the column that holds the description and
that's what gets returned when you access the 'Value'.

Example:

In the Combobox1_Change event...
TextBox1.Text = ComboBox1.Value

...where BoundColumn is set to 2 if that's where the description is:

With ComboBox1
.AddItem "PartNumber1"
.List(0, 1) = "Part Number 1 Description"
End With

So if your spreadsheet list has part numbers in ColA and descriptions
in ColB then you'll want to dump those two cols into an array and put
that as the 'List' instead of just part numbers. Set the ColumnWidths
property to 100,0 or whatever width will display the part number
adequately for the 1st col's width. The 2nd value hides the description
column but that's the 'BoundColumn' and so is what gets returned as its
'Value' when selections are made.

HTH

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ComboBox Selection [email protected] uk Excel Discussion (Misc queries) 1 November 14th 08 09:38 PM
fill combobox depending on selection from another combobox Adam Francis Excel Discussion (Misc queries) 2 July 24th 08 07:39 PM
Combobox items determined by the selection in another combobox Alerion Excel Programming 2 September 13th 06 01:07 PM
Combobox Selection Phil Floyd Excel Programming 0 May 6th 04 09:19 PM
Combobox selection Ian Coates Excel Programming 4 February 5th 04 09:26 AM


All times are GMT +1. The time now is 07:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"