GhostofDoom
12-20-2019, 03:28 AM
Hello,
is there a way so it can be faster loading and adding 2 values in 1 combo
i use this code
but takes ages
and i can't make the last range "B to count instead of 100000
and can't start at A2 either :(
Sub FillCustomers()
ComboBox1.Clear
Dim sSheet As Worksheet, rSource As String
Dim oDictionary As Object
Set sSheet = Sheets("ListCustomers")
Set oDictionary = CreateObject("Scripting.Dictionary") 'get duplicates
For i = 1 To sSheet.Range("A100000:B100000" & Lastrow).End(xlUp).Row
If sSheet.Range("A" & i).Text = "firstname" Then
ElseIf sSheet.Range("B" & i).Text = "name" Then
ElseIf sSheet.Range("A" & i).Text = "" Then
ElseIf sSheet.Range("B" & i).Text = "" Then
Else
If oDictionary.Exists(sSheet.Range("A" & i).Text & " " & sSheet.Range("B" & i).Text) Then
Else
oDictionary.Add sSheet.Range("A" & i).Text & " " & sSheet.Range("B" & i).Text, 0
ComboBox1.AddItem (sSheet.Range("A" & i).Text & " " & sSheet.Range("B" & i).Text)
End If
End If
Next i
Exit Sub
End Sub
Thank you
is there a way so it can be faster loading and adding 2 values in 1 combo
i use this code
but takes ages
and i can't make the last range "B to count instead of 100000
and can't start at A2 either :(
Sub FillCustomers()
ComboBox1.Clear
Dim sSheet As Worksheet, rSource As String
Dim oDictionary As Object
Set sSheet = Sheets("ListCustomers")
Set oDictionary = CreateObject("Scripting.Dictionary") 'get duplicates
For i = 1 To sSheet.Range("A100000:B100000" & Lastrow).End(xlUp).Row
If sSheet.Range("A" & i).Text = "firstname" Then
ElseIf sSheet.Range("B" & i).Text = "name" Then
ElseIf sSheet.Range("A" & i).Text = "" Then
ElseIf sSheet.Range("B" & i).Text = "" Then
Else
If oDictionary.Exists(sSheet.Range("A" & i).Text & " " & sSheet.Range("B" & i).Text) Then
Else
oDictionary.Add sSheet.Range("A" & i).Text & " " & sSheet.Range("B" & i).Text, 0
ComboBox1.AddItem (sSheet.Range("A" & i).Text & " " & sSheet.Range("B" & i).Text)
End If
End If
Next i
Exit Sub
End Sub
Thank you