+ Reply to Thread
Results 1 to 4 of 4

Efficient VBA method for looking up cell values - dynamic sheet references and arrays

  1. #1
    Registered User
    Join Date
    03-24-2021
    Location
    UK
    MS-Off Ver
    2016
    Posts
    2

    Efficient VBA method for looking up cell values - dynamic sheet references and arrays

    Hi All

    First post here.

    I have a workbook that contains price data for various stocks. Each company has it's own sheet (sheet name = Ticker) with columns A:G populated as follows: Dates; Open; High; Low; Close; Adj Close; Volume.

    In a front sheet, called "Portfolio Prices" I have a list of company tickers running across B1:Y1. Based on those tickers, I am trying to import Adj Close prices from the various sheets in cells B8:Y#.

    All companies have different lengths of price data. I have found a way to copy the dates from the shortest time-series into the "Portfolio Prices" sheet with a macro and helper cell (B5). From there, I want to populate the various columns B8:Y# based on the sheet names in cells B1:Y1 and the dates in A8:A#. I'm not great with VBA, but I found a way to do this using a looped vlookup function over the entire dynamic array. It works, but it is incredibly slow. I'd be lucky to populate 10 cells a second.

    Given that the size of the array to calculate might be 100,000+ cells, I need a much faster method. Any ideas?

    I've attached the XLSM to this post so you can see what I have been working on.

    Thanks
    Chris
    Attached Files Attached Files

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Efficient VBA method for looking up cell values - dynamic sheet references and arrays

    Add these lines:


    Please Login or Register  to view this content.
    around main loop. It definitely helps.
    test: It fully populated everything in 1-2 seconds.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,519

    Re: Efficient VBA method for looking up cell values - dynamic sheet references and arrays

    Try
    Please Login or Register  to view this content.

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Efficient VBA method for looking up cell values - dynamic sheet references and arrays

    Another approach...
    Please Login or Register  to view this content.

+ 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. Efficient way to transpose values from one sheet to another
    By FallingDown in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-06-2018, 01:32 PM
  2. Seeking more efficient method to check multiple tab headers and storing in arrays
    By Douglas_D in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2016, 03:23 PM
  3. Replies: 4
    Last Post: 09-16-2014, 07:48 AM
  4. Replies: 1
    Last Post: 02-18-2012, 10:31 AM
  5. A More Efficient Method Than the Evaluate Method?
    By anthony.mcgovern in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-22-2011, 05:39 AM
  6. [SOLVED] Comparing two arrays what the best most efficient way
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-08-2011, 08:19 AM
  7. Efficient Arrays?
    By Mark in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-24-2005, 02:05 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