Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How remove duplicate values when taking data from excel to VB 6?

Status
Not open for further replies.

Niki_S

Programmer
Jun 4, 2021
232
0
0
LK
My code is as below and I want to remove duplicates when taking data from excel.

Code:
  vArray = oXLSheet.Range("E12:E140").Value
  vArray1 = oXLSheet.Range("U12:U140").Value


    cboOperation.Clear
   For lngRow = LBound(vArray, 1) To UBound(vArray, 1)
    If Not IsEmpty(vArray(lngRow, 1)) Then

            cboOperation.AddItem vArray(lngRow, 1)
    
    End If
   Next lngRow

The result from this is as below,

Code:
179
234
567
179
657
234

But I want to take my output as,

Code:
179
234
567
657

How can I take my output?

Thank you.
 
What have you tried so far?
Show some effort.

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
I did something like this.

Code:
Dim position As Integer
Dim position2 As Integer


 cboOperation.Clear
   For lngRow = LBound(vArray, 1) To UBound(vArray, 1)
    If Not IsEmpty(vArray(lngRow, 1)) Then
        position = InStr(1, vArray(lngRow, 1))
        If position > 0 Then
            cboOperation.AddItem vArray(lngRow, 1)
        End If
    End If
   Next lngRow


 For lngRow = LBound(vArray1, 1) To UBound(vArray1, 1)
    If Not IsEmpty(vArray1(lngRow, 1)) Then
        position2 = InStr(1, vArray(lngRow, 1))
        If position2 > 0 Then
            cboOperation.AddItem vArray1(lngRow, 1)
        End If
    End If
   Next lngRow
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top