how do i use this code please

d0wnt0wn

Well-known Member
Joined
Oct 28, 2002
Messages
771
Private Sub Worksheet_Activate()
Dim i As Integer
ComboBox1.Clear
For i = 1 To ActiveSheet.Scenarios.Count
ComboBox1.AddItem ActiveSheet.Scenarios(i).Name
Next
ComboBox1.Text = "Select Scenario"
End Sub

Private Sub ComboBox1_Click()
On Error Resume Next
ActiveSheet.Scenarios(ComboBox1.Text).Show
End Sub


where do i put the pieces of code and how do i link a combobox to it... sorry for my stupidity
 
Is the combobox being populated with your scenarios?

Are the all listed when you click the arrow?

Is 'bsb 2 ply' the first item on the list?
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
oh my god!!!! right after i posted that to you i went to my sheet and the combobox was populating.........this is working perfectly now.....thanks everyone for putting up with me!
 
Upvote 0
uggg list is not populating again..... i close the work book then open again and the list is gone :O(
 
Upvote 0
I dont really know what your after, but if you need Combo box to display a list of things here is the way to do it.

ComboBox1.AddItem "Jan"
ComboBox1.AddItem "Feb"
ComboBox1.AddItem "March"
ComboBox1.AddItem "April"
ComboBox1.AddItem "May"
ComboBox1.AddItem "June"
 
Upvote 0
d0wnt0wn said:
uggg list is not populating again..... i close the work book then open again and the list is gone :O(

The Worksheet_Activate event doesn't fire when you open a workbook. It fires when you click the sheet tab while another sheet is active, or when you Page Up or Down to the sheet from another sheet.

You could put some code in the Workbook_Open event procedure (in the ThisWorkbook module) that activates another sheet then activates the sheet containing the ComboBox.
 
Upvote 0

Forum statistics

Threads
1,224,845
Messages
6,181,301
Members
453,031
Latest member
Chris_1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top