+ Reply to Thread
Results 1 to 7 of 7

Look Up Values with 7000+ data points

Hybrid View

  1. #1
    Registered User
    Join Date
    06-28-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    10

    Look Up Values with 7000+ data points

    I pull a list of bonds daily and I have a formula that calculates a score. I then need to input those the scores into a database on another sheet that already has existing bonds names and scores. The daily data pull consists of new bonds and also existing bonds that are in my database. I am trying to have new bonds be added to the database with score and name while existing bonds just have the score copied into the correct row and column (by bond name and date).

    I tried using a nested for loop where I take one bond name from the new list and compare it to each bond name on the old list but with 7000+ bond names daily, the VBA program takes too long.

    Is there anyway to use an existing Excel function with VBA to make this process faster and more efficient?
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Look Up Values with 7000+ data points

    It means using your example that
    The last value on the right for Bond 2 : 5.67494476999126
    will erase cell B4 (71.9135564307521) in sheet "NewData"
    Is it
    - Battle without fear gives no glory - Just try

  3. #3
    Registered User
    Join Date
    06-28-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Look Up Values with 7000+ data points

    NewData is the sheet that contains the daily pulled information.

    I want to take cell B4 in NewData and add it to cell G3 in the Database sheet. Column G would represent today's bond scores.

    The Database sheet will keep a historic record of bond scores that are pulled daily.

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Look Up Values with 7000+ data points

    Is that means that columns C, D, E ,F in sheet "NewData" have already data ?
    It means the last column of sheet "Database" must be copid to the last column of sheet "Newdata" ?

  5. #5
    Registered User
    Join Date
    06-28-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Look Up Values with 7000+ data points

    Quote Originally Posted by PCI View Post
    Is that means that columns C, D, E ,F in sheet "NewData" have already data ?
    It means the last column of sheet "Database" must be copid to the last column of sheet "Newdata" ?
    Columns C, D, E, F will never have data. The daily pull only generates the name of the bond of the score.

  6. #6
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Look Up Values with 7000+ data points

    Is it what you need ...?
    Option Explicit
    
    Sub Treat()
    Dim InRg As Range, OutRg As Range
    Dim ObjDic   As Object
    Set ObjDic = CreateObject("Scripting.Dictionary")
    Dim InWS  As Worksheet, OutWS  As Worksheet
    Dim LR  As Integer, LC As Integer, I As Integer
    Dim F
    
        Set InWS = Sheets("Database")
        Set OutWS = Sheets("NewData")
        
        Set OutRg = Sheets("NewData").UsedRange
        Set InRg = Sheets("Database").UsedRange
        With InWS
            LR = .Cells(Rows.Count, 1).End(xlUp).Row
            LC = .Cells(1, Columns.Count).End(xlToLeft).Column
            For I = 2 To LR
                ObjDic.Item(.Cells(I, 1).Value) = .Cells(I, LC).Value
            Next
        End With
    
        With OutWS
            LR = .Cells(Rows.Count, 1).End(xlUp).Row
            LC = .UsedRange.Columns.Count
            For I = 3 To LR
                If (ObjDic.exists(.Cells(I, 1).Value)) Then
                    .Cells(I, LC + 1).Value = ObjDic.Item(.Cells(I, 1).Value)
                    ObjDic.Remove (.Cells(I, 1).Value)
                End If
            Next
            For Each F In ObjDic.keys
                LR = LR + 1
                .Cells(7, 1) = F
                .Cells(7, LC) = ObjDic.Item(F)
            Next
        End With
    End Sub
    Attached Files Attached Files
    Last edited by PCI; 06-26-2015 at 01:18 PM.

  7. #7
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Look Up Values with 7000+ data points

    A slightly different approach. Assuming that you wish to add new data to the next empty column the macro will find the first empty column in the "Database" sheet and copy the data from the "NewData" to that empty column.

    To test run macr "Adder" from the "Database" sheet.

    Alf
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Want my formula to max the results at 7000
    By Randybrn2 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-26-2015, 12:18 PM
  2. [SOLVED] Correct way to =IF(B6<7000,B6*0.45)=IF(B6<97000,B6*0.5) ...etc
    By cbrock in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 04-13-2014, 09:04 AM
  3. HELP! Adding numbers from 7000 - 60,000 Automatically
    By puchimo in forum Excel General
    Replies: 27
    Last Post: 11-15-2012, 05:38 AM
  4. Assigning points values to data to set performance rankings...
    By stateofstatic in forum Excel General
    Replies: 3
    Last Post: 01-28-2012, 09:23 PM
  5. Assigning values to data points
    By charmandering in forum Excel General
    Replies: 4
    Last Post: 03-23-2010, 09:34 PM

Tags for this Thread

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