I have the following code
Code: Select all
Private Sub ComboBox1_Change()
Dim ws As Worksheet
Dim a As Variant
Dim b() As Variant
Dim temp As Variant
Dim i As Long
Dim x As Long
Set ws = ThisWorkbook.Worksheets("Sheet1")
x = Me.ComboBox1.ListIndex
temp = Me.ComboBox1.Value
If (x = -1) + (temp = "") Then Exit Sub
If IsNumeric(temp) Then temp = Val(temp)
a = ws.Range("A1:L" & ws.Cells(Rows.Count, 12).End(xlUp).Row).Value
ReDim b(1 To 1): b(1) = Application.Index(a, 1, 0)
For i = 2 To UBound(a, 1)
If temp Like "*" & a(i, 12) & "*" Then
ReDim Preserve b(1 To UBound(b) + 1)
b(UBound(b)) = Application.Index(a, i, 0)
End If
Next i
If UBound(b) > 0 Then
If UBound(b) = 1 Then
Me.ListBox1.Column = Application.Index(b, 0, 0)
Else
Me.ListBox1.List = Application.Index(b, 0, 0)
End If
End If
End Sub
What I am searching for and know about ....
First Is using ReDim Preserve will be slow when dealing with large data of 1 million rows and 25 columns?
The same question for using Application.Index ..??
How can I fill the listbox using arrays without using Application.Index or ReDim Preserve which I think is the cause of slow process..?
I don't need the above code but need a sample or example code that only uses arrays with the fastest in performance and speed
Thanks advanced for help