Dear frenz,
i need a solution to fasten the process of my macro, its taking almost 1 hour to complete the process.....the macro as below
Option Explicit
Public Function MatchDigits(LookupValue As Range, LookupRange As Range) As String
Dim Cell As Range
Dim NewNum As String
Dim TempNum As String
Dim Num As Long
Dim i As Long
Dim j As Long
For Each Cell In LookupRange
Num = Len(Cell) - (Len(LookupValue) - 1)
For i = 1 To Num
NewNum = Mid(Cell, i, Len(LookupValue))
TempNum = NewNum
For j = 1 To Len(LookupValue)
TempNum = Replace(TempNum, Mid(LookupValue, j, 1), "", , 1)
Next j
If Len(TempNum) = 0 Then
MatchDigits = NewNum
Exit Function
End If
Next i
Next Cell
MatchDigits = 0
End Function
there is 7 columns and 1000 rows of data, the function of this macro is to match the digits, and the process using this method is really too long to process....is there is shortcut or a formula that is able to cut the time of processing?
pls do really help. thanks in advance
i need a solution to fasten the process of my macro, its taking almost 1 hour to complete the process.....the macro as below
Option Explicit
Public Function MatchDigits(LookupValue As Range, LookupRange As Range) As String
Dim Cell As Range
Dim NewNum As String
Dim TempNum As String
Dim Num As Long
Dim i As Long
Dim j As Long
For Each Cell In LookupRange
Num = Len(Cell) - (Len(LookupValue) - 1)
For i = 1 To Num
NewNum = Mid(Cell, i, Len(LookupValue))
TempNum = NewNum
For j = 1 To Len(LookupValue)
TempNum = Replace(TempNum, Mid(LookupValue, j, 1), "", , 1)
Next j
If Len(TempNum) = 0 Then
MatchDigits = NewNum
Exit Function
End If
Next i
Next Cell
MatchDigits = 0
End Function
there is 7 columns and 1000 rows of data, the function of this macro is to match the digits, and the process using this method is really too long to process....is there is shortcut or a formula that is able to cut the time of processing?
pls do really help. thanks in advance