Hi,
I am trying to lookup data series via a key(ISIN or Valor). I have built a macro that works but it is very slow when I use it for a larger file. I have attached a small example.
(normal file is about 15000 line)
Maybe there is a way to return a complete data row after identifying a match.
Your help is very much appreciated.
Kind regards
Joost
This is the code:
(also in attachment with data sample)
Code
Sub retrieveSeries()
' start
jRow = 10
jCol = 1
lRow = 8
lCol = 2
sWK1 = "output"
sWK2 = "series"
Sheets(sWK1).Activate
Do Until Cells(jRow, jCol) = ""
Do Until lRow = 20000 Or Sheets(sWK2).Cells(lRow, lCol) = Cells(jRow, jCol) ' first search for valor
lRow = lRow + 1
Loop
If lRow = 20000 Then ' valor not found
lRow = 8
Do Until lRow = 20000 Or Sheets(sWK2).Cells(lRow, lCol - 1) = Cells(jRow, jCol + 1) 'search for isin
lRow = lRow + 1
Loop
If lRow = 20000 Then
lCol = 2 'dataseries NOT found
Else
Call retrieveLNofSeries ' retrieve series via ISIN
End If
Else
Call retrieveLNofSeries ' retrieve series via VALOR
End If
lRow = 8
jRow = jRow + 1
Loop
End Sub
Sub retrieveLNofSeries()
'****Retrieves the LN of the serie****
Do Until Application.WorksheetFunction.IsNumber(Sheets(sWK2).Cells(lRow, lCol + 3)) = False
Cells(jRow, jCol + 3) = Application.WorksheetFunction.Ln((Sheets(sWK2).Cells(lRow, lCol + 3) / 100) + 1) ' calculates the lnof the data
jCol = jCol + 1
lCol = lCol + 1
Loop
Cells(jRow, 11) = Sheets(sWK2).Cells(lRow, 12) 'return size
lCol = 2
jCol = 1
End Sub
Display More