I have the following code in the Change procedure of a checkbox on a userfrom. What I want is if the box is checked then the ComboBox (SummaryFiles) gets its list from Col G of the Summary Files sheet, and if it is NOT checked then get it's list from column H. This IS NOT working for me at all. I have the Column H section in the Initialize code at first, but then if a user checks the Show All box then the list does not get refreshed, it gets appended to. Basically this list will show more files than what is on the sheet. It is not refreshing, it is appending this list.
Does anyone know how to make the source change from one column to another for a combobox?
Private Sub ShowAll_Change()
Dim Rng As Range
Dim i As Long
Sheets("Product Receipt").Select
If ShowAll.Value = True Then
Me.SummaryFiles.RowSource = ""
Set Rng = Sheets("Summary Files").Range("G:G")
For i = 1 To Rng.Rows.Count
If Rng(i) <> "" Then
Me.SummaryFiles.AddItem Rng(i)
End If
Next i
Else
Me.SummaryFiles.RowSource = ""
Set Rng = Sheets("Summary Files").Range("H:H")
For i = 1 To Rng.Rows.Count
If Rng(i) <> "" Then
Me.SummaryFiles.AddItem Rng(i)
End If
Next i
End If
Me.SummaryFiles.SetFocus
End Sub
Private Sub UserForm_Initialize()
Me.SummaryFiles.SetFocus
End Sub
Bookmarks