Hello
Can u help to create a script that will popup a user form asking to select an option from the list. the option selected should then reflect in one of the cell in sheet2 and the form should close automatically..
Regards
Skopweb
Hello
Can u help to create a script that will popup a user form asking to select an option from the list. the option selected should then reflect in one of the cell in sheet2 and the form should close automatically..
Regards
Skopweb
Show the form on workbook enter and get the value. Make sure that form gets hidden on close not unloaded.
[vba]
Private Sub Workbook_Open()
With Userform1
.Show
Worksheets("Sheet1").Range("A2").Value = .cmbList.Value
End With
End Sub
[/vba]
This is workbook event code.
To input this code, right click on the Excel icon on the worksheet
(or next to the File menu if you maximise your workbooks),
select View Code from the menu, and paste the code
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Thanks XLD
i tried using for the combobox and it works
--------------------------------
[VBA]Private Sub Workbook_Open()
With UserForm1
.Show
Worksheets("Sheet1").Range("A2").Value = .ComboBox1.Value
End With
End Sub[/VBA]
--------------------------------
however can u tell me how can i enter the list of values to be selected from the combobox and once its selected the the form should close.
the combo box should not take any other values than the one in the list
Regards
Skopweb
Where are those values, in the code or a worksheet?
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
hello xld
i just have 4 options to select but i have no preference if it should be in the code or in the list....
can u let me know both of it so i can select the appropirate one...
regards
skopweb
With only 4 items, and assuming they don't change I would put then in the code
[VBA]Private Sub UserForm_Initialize()[/VBA]
ComboBox1.List = Array("Item1", "Item2", "Item3", "Item4")
End Sub
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
thanks it works.....
but once the item is selected.. can the form close automatically
Yes.
Just add Unload code to the Click event of the Combobox.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
thanks this works the way i wanted..
regards
skopweb