mattkorguk
Registered User.
- Local time
- Today, 01:23
- Joined
- Jun 26, 2007
- Messages
- 301
Hi,
I've been trying to get the below to work on a list 42000+ id's and it does work fine on the first 156 lines, no problem, returning as expected. When I try and copy the formula to line 157 it just freezes...
The below was taken from MrExcel site I believe...
If you break the code it seems like it's stuck in a loop here;
Any ideas?!? Thanks.
I've been trying to get the below to work on a list 42000+ id's and it does work fine on the first 156 lines, no problem, returning as expected. When I try and copy the formula to line 157 it just freezes...

The below was taken from MrExcel site I believe...

Code:
'Vlookup Multiple Criteria
'Returns all values matching vlookup criteria, separated by a comma
'=mvlookup(a1,sheet2!$a$1:$c$43000,4)
Function mvlookup(lookupValue, tableArray As Range, colIndexNum As Long, _
Optional NotUsed As Variant) As Variant
Dim initTable As Range
Dim myRowMatch As Variant
Dim myRes() As Variant
Dim myStr As String
Dim initTableCols As Long
Dim i As Long
Dim ubound_myRes As Long
Set initTable = Nothing
On Error Resume Next
Set initTable = Intersect(tableArray, tableArray.Parent.UsedRange.EntireRow)
On Error GoTo 0
If initTable Is Nothing Then
mvlookup = CVErr(xlErrRef)
Exit Function
End If
initTableCols = initTable.Columns.Count
i = 0
Do
myRowMatch = Application.Match(lookupValue, initTable.Columns(1), 0)
If IsError(myRowMatch) Then
Exit Do
Else
i = i + 1
ReDim Preserve myRes(1 To i)
myRes(i) _
= initTable(1).Offset(myRowMatch - 1, colIndexNum - 1).Text
If initTable.Rows.Count <= myRowMatch Then
Exit Do
End If
On Error Resume Next
Set initTable = initTable.Offset(myRowMatch, 0).Resize(initTable.Rows.Count - myRowMatch, initTableCols)
On Error GoTo 0
If initTable Is Nothing Then
Exit Do
End If
End If
Loop
If i = 0 Then
mvlookup = CVErr(xlErrNA)
Exit Function
End If
myStr = ""
For i = LBound(myRes) To UBound(myRes)
myStr = myStr & ", " & myRes(i)
Next i
mvlookup = Mid(myStr, 3)
End Function
Code:
ReDim Preserve myRes(1 To i)
myRes(i) _
= initTable(1).Offset(myRowMatch - 1, colIndexNum - 1).Text
If initTable.Rows.Count <= myRowMatch Then
Exit Do
Any ideas?!? Thanks.