![]() |
Excel forms And combo boxes
I am setting up a VB form inside an Excel workbook. I have put a Combo box on
the form. My problem is linking the data for the combo box to a column on the work sheet. Does any one have an easy to follow example please? |
Excel forms And combo boxes
Use the following change event for the combobox:
Private Sub ComboBox1_Change() Worksheets("Sheet1").Range("A1") = ComboBox1.Value End Sub Mangesh "Rob" wrote in message ... I am setting up a VB form inside an Excel workbook. I have put a Combo box on the form. My problem is linking the data for the combo box to a column on the work sheet. Does any one have an easy to follow example please? |
Excel forms And combo boxes
Thanks for the reply, the answer was similar to what was applied to the VBA,
& was modified acordingly (mainly it was abreviated) but the list box in the form will not display the range value. It appears I've missed something, I have tried both options, Data validation & range value either doesn't work. To be honest as this is a sub form and the range is only aprox. ten (was only using this option for modification purpose so the form wouldn't need to be modified in the future only the worksheet). I may do it by check boxes or command button. Still it would be nice to get the list box going as a need for it later will be applicable. "Rob" wrote: I am setting up a VB form inside an Excel workbook. I have put a Combo box on the form. My problem is linking the data for the combo box to a column on the work sheet. Does any one have an easy to follow example please? |
Excel forms And combo boxes
I think I am missing something, you want to populate the combobox with the
values in a range or the other way round...? My earlier post gave a solution where the combo-box value goes to an excel cell, for the reverse, you need to do the following: Private Sub UserForm_Initialize() ComboBox1.RowSource = "Sheet1!A1:A10" End Sub or simply go to the properties and enter Sheet1!A1:A10 in the rowsource property Mangesh "Rob" wrote in message ... Thanks for the reply, the answer was similar to what was applied to the VBA, & was modified acordingly (mainly it was abreviated) but the list box in the form will not display the range value. It appears I've missed something, I have tried both options, Data validation & range value either doesn't work. To be honest as this is a sub form and the range is only aprox. ten (was only using this option for modification purpose so the form wouldn't need to be modified in the future only the worksheet). I may do it by check boxes or command button. Still it would be nice to get the list box going as a need for it later will be applicable. "Rob" wrote: I am setting up a VB form inside an Excel workbook. I have put a Combo box on the form. My problem is linking the data for the combo box to a column on the work sheet. Does any one have an easy to follow example please? |
Excel forms And combo boxes
Thanks the reply, the info was useful, though didn't use it in the end mainly
because I believe I was trying to get the userform to read into the worksheet rather than the otherway round which it worked. Now I am stuck again. In general what I am trying to achieve, is once an item has been selected, a message box appears for conformation which works, unfortunately if the item selected is incorrect, is to close the message box and restart from list box, this sorts of work though it remembers the list box original value which is is incorrect us aready stated. Attached is a copy of what was produced, would somebody explain where I have gone wrong please & wheter I should be using a loop system & wheter stating the list box values is applicable? Which is actually being read from a seperate worksheet sheet, also I'd like the message box to only appear once during conformation. Sub ListBox1_Click() MsgBox "You Have Selected_" & ListBox1.Value & "_Do You Wish To Continue?", vbYesNo UserForm1.Hide If MsgBox("Continue?", vbYesNo) < vbYes Then Call UserForm1_Click ElseIf ListBox1.Value = "400kV" Then Call GIS_Voltage1_Sorter ElseIf ListBox1.Value = "300kV" Then Call GIS_Voltage1_Sorter ElseIf ListBox1.Value = "230kV" Then Call GIS_Voltage1_Sorter ElseIf ListBox1.Value = "130kV" Then Call GIS_Voltage_Sorter ElseIf ListBox1.Value = "66kV" Then Call GIS_Voltage_Sorter ElseIf ListBox1.Value = "33kV" Then Call S33kV_Sorter ElseIf ListBox1.Value = "11kV" Then Call S11kV_Sorter ElseIf ListBox1.Value = "Ancillary" Then Call Ancillary_Sorter ElseIf ListBox1.Value = "Master" Then Call Master_Sorter End If Call UserForm1_Click End Sub "Rob" wrote: Thanks for the reply, the answer was similar to what was applied to the VBA, & was modified acordingly (mainly it was abreviated) but the list box in the form will not display the range value. It appears I've missed something, I have tried both options, Data validation & range value either doesn't work. To be honest as this is a sub form and the range is only aprox. ten (was only using this option for modification purpose so the form wouldn't need to be modified in the future only the worksheet). I may do it by check boxes or command button. Still it would be nice to get the list box going as a need for it later will be applicable. "Rob" wrote: I am setting up a VB form inside an Excel workbook. I have put a Combo box on the form. My problem is linking the data for the combo box to a column on the work sheet. Does any one have an easy to follow example please? |
All times are GMT +1. The time now is 07:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com