My code below, it is a combo box on a userform which allows the user to select certain data from other worksheets. My problem is, it also shows my 'Summary' sheet as a selectable option. How do I get it to show all worksheets in list index excluding the 'summary' worksheet?
Private Sub cmb_copycontact_Change()
If cmb_copycontact.ListIndex <> -1 Then
With ActiveWorkbook.Sheets(cmb_copycontact.Value)
txt_MailAdd1.Value = .Range("B21").Value
txt_mailadd2.Value = .Range("B22").Value
txt_mailburb.Value = .Range("B23").Value
cmb_mailstate.Value = .Range("B24").Value
txt_pcode.Value = .Range("B25").Value
End With
End If
End Sub
As UGP stated, exclude the Summary Sheet while populating the ComboBox on UserForm.
Incorporate the following code into your UserForm Initialize Event code.
Private Sub UserForm_Initialize()
Dim ws As Worksheet
For Each ws In Worksheets
If ws.Name <> "Summary" Then
Me.cmb_copycontact.AddItem ws.Name
End If
Next ws
End Sub