I have 3 worksheets in my Activeworkbook. Worksheet 1 has number 101,102,1000,1001,1002 in it in vertical format in column A. Worksheet 2 has number 101,102,1000,1001,1002,1003,1004 in it in vertical format in column A. Worksheet 3 has 101,102,1000,1001,1002,1003 in it in vertical form also in Column A. I have done the initialization VBA coding to initialize those numbers into my combobox, instead of loading those UNIQUE numbers into my combobox, it load all the numbers into my combobox and as a result I have duplicate items in my commbox (for example, number 101 appear 3 times instead of appearing only once in my combobox). Here is my VBA coding:-
Private Sub UserForm_Initialize()
Dim intIndex As Integer
Dim shtThisSheet As Worksheet
Dim strServiceID As String
Dim rngData As Range
Dim rngCell As Range
'set range table
For intIndex = 1 To 3
Set shtThisSheet = ActiveWorkbook.Worksheets(intIndex)
shtThisSheet.Activate
'currentregion to find range with data
Set rngData = shtThisSheet.Range("A3").CurrentRegion
Set rngData = rngData.Offset(Rowoffset:=2) _
.Resize(rowsize:=rngData.Rows.Count - 3, ColumnSize:=rngData.Columns.Count - 6)
'assign column heading strServiceID variable
strServiceID = "ServiceID"
'sort ServiceID data, then add only unique ServiceIDs to combobox
rngData.Sort key1:=strServiceID, header:=xlYes
For Each rngCell In rngData.Cells
If rngCell.Value <> strServiceID Then
cboAddExistingDataSelectServiceID.AddItem rngCell.Value
End If
Next rngCell
Next intIndex
End Sub
All help is very much appreciated. Thank you.