MelindaMartin
New Member
- Joined
- Dec 19, 2016
- Messages
- 6
I have a combox box that allows me to select a worksheet name from a drop down list and then it takes me to that worksheet. That part is awesome.
It works in conjunction with a command button. The command button generates the combobox with the worksheet names. This part is not awesome.
My goal is to have the combobox automatically update with the workbook's current worksheets and to not have a command button at all--just to have the combobox.
The combobox code is:
Private Sub ComboBox1_Change()
Dim ws As Worksheet
On Error Resume Next
Set ws = ThisWorkbook.Sheets(ComboBox1.Value)
ws.Select
On Error GoTo 0
End Sub
The command box code is:
Private Sub CommandButton1_Click()
Dim n As Long
For n = 1 To ActiveWorkbook.Sheets.Count
ComboBox1.AddItem ActiveWorkbook.Sheets
.Name
Next n
End Sub
How do I get the combobox to automatically update with any new and/or deleted worksheet names?
TIA
It works in conjunction with a command button. The command button generates the combobox with the worksheet names. This part is not awesome.
My goal is to have the combobox automatically update with the workbook's current worksheets and to not have a command button at all--just to have the combobox.
The combobox code is:
Private Sub ComboBox1_Change()
Dim ws As Worksheet
On Error Resume Next
Set ws = ThisWorkbook.Sheets(ComboBox1.Value)
ws.Select
On Error GoTo 0
End Sub
The command box code is:
Private Sub CommandButton1_Click()
Dim n As Long
For n = 1 To ActiveWorkbook.Sheets.Count
ComboBox1.AddItem ActiveWorkbook.Sheets

Next n
End Sub
How do I get the combobox to automatically update with any new and/or deleted worksheet names?
TIA