+ Reply to Thread
Results 1 to 2 of 2

Promblem with finding an item in a list

  1. #1
    Registered User
    Join Date
    11-26-2003
    Posts
    3

    Promblem with finding an item in a list

    I have a large list of securities (4000+)where i need to retrieve data from an even longer list of data items(8000+).
    I have setup up the macro to read the first itme in the security list then loop down through the data item list until it finds the relevant data item. This is repeated for each of the entries in the security list.
    Please see the code for the macro below.

    Sub Get_Price_Data()
    '
    ' Get_Price_Data Macro
    ' Macro recorded 18/04/2005 by u5108
    Application.ScreenUpdating = False

    Dim Valuation_Sedol As String
    Dim Price_Sedol As String
    Dim Price As Double
    Dim Price_Date As String
    Dim Price_Currency As String
    Dim ValuationIndex As Integer
    Dim PriceIndex As Integer

    ValuationIndex = 2
    PriceIndex = 2


    Sheets("Valuation").Select
    Range("A2").Select

    Do
    Valuation_Sedol = Cells(ValuationIndex, 2)


    If Valuation_Sedol <> Cells(ValuationIndex - 1, 2) Then

    Sheets("Prices").Select
    Range("A2").Select

    PriceIndex = 2
    Do
    Price_Sedol = Cells(PriceIndex, 1)
    Price = Cells(PriceIndex, 2)
    Price_Date = Cells(PriceIndex, 3)
    Price_Currency = Cells(PriceIndex, 4)
    PriceIndex = PriceIndex + 1
    Loop While Price_Sedol <> Valuation_Sedol

    Sheets("Valuation").Select

    Else
    End If


    Cells(ValuationIndex, 4) = Price
    Cells(ValuationIndex, 5) = Price_Currency

    ValuationIndex = ValuationIndex + 1

    Loop While Valuation_Sedol <> ""


    End Sub


    The problem is that this macro takes 10+ minutes to run. Does anyone have ant ideas how I can get the macro to run faster. I do not want to use vlookup formulas within the sheet.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Lorcanjc,

    Your code is as lean as it can get. You didn't state what processor you have. I would suggest running the macro and workbooks on a faster CPU. This is only way you are going to reduce the time.

    Sincerely,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1