Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Combo Box help!

Hi,
This maybe simple, but I'm new to VB.
1) Ok, I want to make up a combo box which consists of cell value
B4:B48. Any column can be empty sometimes therefore, the combo bo
should be populated only with non-null values.

2) Also, when the user click on any one of the items from the comb
box, the values of their corresponding rows should be displayed i
their respective textboxs which are already placed on the user form.
For example, if the item on the combo list is 'Soda' (B5) then it
corresponding textboxs for rows 'Close' (C5) & 'Open' (D5) shoul
display its value in the textbox automatically.

Sorry for this mess, I hope you understand what i'm trying to acheiv
:)

- Kkha

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Combo Box help!

Private Sub Userform_Initialize()
Dim cell as Range
Combobox1.rowsource = ""
with worksheets("Sheet1")
for each cell in .Range("B4:B48")
if len(trim(cell.text)) 0 then
Combobox1.AddItem cell.Value
end if
Next
End With

Private Sub Combobox1_Click()
Dim res as Variant
Dim rng as Range, rng1 as Range
with worksheets("Sheet1")
set rng = .Range("B4:B48")
End With
res = Application.Match(Combobox1.Value,rng,0)
if not iserror(res) then
set rng1 = rng(res)
Textbox1.Text = rng1.offset(0,1).Value
Textbox2.Text = rng1.offset(0,2).Value
Else
Textbox1.Text = ""
Textbox2.Text = ""
end if
End Sub

--
Regards,
Tom Ogilvy




"kkhan " wrote in message
...
Hi,
This maybe simple, but I'm new to VB.
1) Ok, I want to make up a combo box which consists of cell values
B4:B48. Any column can be empty sometimes therefore, the combo box
should be populated only with non-null values.

2) Also, when the user click on any one of the items from the combo
box, the values of their corresponding rows should be displayed in
their respective textboxs which are already placed on the user form.
For example, if the item on the combo list is 'Soda' (B5) then its
corresponding textboxs for rows 'Close' (C5) & 'Open' (D5) should
display its value in the textbox automatically.

Sorry for this mess, I hope you understand what i'm trying to acheive
:)

- Kkhan


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Combo Box help!

can't thank you enough for this tom...i've one more question for
anyone.....
its simple..
how do u get add that command button which pops up when the workbook
opens? its this command button that triggers the macro...anyone know
what i'm talking about ?
thanks in advance...


---
Message posted from http://www.ExcelForum.com/

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
How do I create a combo box that is tied to another combo box? rosamaria Excel Worksheet Functions 2 December 9th 09 10:32 PM
linking a form combo box... results from the combo box to another Trey Excel Discussion (Misc queries) 1 July 15th 07 01:58 AM
combo reference on another combo box for picking address etc. kbjin Excel Worksheet Functions 1 December 8th 06 03:29 PM
"Combo Box - getting control combo box to stick in place in worksh ajr Excel Discussion (Misc queries) 1 February 16th 05 02:05 AM
"Combo Box - getting control combo box to stick in place in worksh ajr Excel Discussion (Misc queries) 0 February 15th 05 07:45 PM


All times are GMT +1. The time now is 06:48 AM.

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

About Us

"It's about Microsoft Excel"