View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Doug Glancy Doug Glancy is offline
external usenet poster
 
Posts: 770
Default Refresh combobox after inserting new sheet

Brian,

Paste this code in the ThisWorkbook code module in the VB editor. It
assumes a "ComboBox1" in "Sheet1." The code runs each time a new sheet is
activated, which happens whenever you insert or delete a sheet:

Private Sub Workbook_SheetActivate(ByVal Sh As Object)

Dim ws As Worksheet

With Worksheets("Sheet1").ComboBox1
.Clear
For Each ws In ThisWorkbook.Worksheets
.AddItem ws.Name
Next ws
End With

End Sub

hth,

Doug

"Duke17 " wrote in message
...
Hi,

I'm really new to VBA programming, but I'm trying to learn from
everyone here. :)

I have an ActiveX ComboBox that is populated with the names of all the
worksheets. All I want to do is refresh the list of worksheet names in
the combobox whenever a worksheet is added or deleted from the
workbook.

Any ideas?

Thanks,
Brian


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