+ Reply to Thread
Results 1 to 4 of 4

Using VBA to create a big table from two tables that reference each other - Too Slow

  1. #1
    Registered User
    Join Date
    11-23-2023
    Location
    Brisbane, Australia
    MS-Off Ver
    365
    Posts
    3

    Using VBA to create a big table from two tables that reference each other - Too Slow

    Hello,

    I have written a macro that creates a new Table based on the values (rows and columns) of Table1 but adds in the Values of a referenced Table2. Replicating a many to one relationship to create a combined solution. The macro works fine but as the tables are getting larger (Table 1 has 400 rows and Table 2 has 150 rows and Columns to CQ), the macro now takes several minutes to complete.

    The macro simple loops through each row of table 1 and then uses the referenced column to replicate all the related rows in the lookup table. I'm wondering if there a different method that isn't so intensive and time consuming?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Using VBA to create a big table from two tables that reference each other - Too Slow

    Hi there,

    We'd probably be much more inclined to investigate a solution if we had a typical workbook to "play" with - can you post something to help us out here?

    I suspect that a large part of the execution time is taken up by copying values one cell at a time. A much more efficient way to copy and paste is to assign the values in the source range to an array, and to then use the values in that array to populate the cells in the target range.

    These "assign" and "populate" operations are performed in bulk rather than on a cell-by-cell basis.

    I might be able to suggest something a bit more specific if I could see what your workbook looks like.

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    11-23-2023
    Location
    Brisbane, Australia
    MS-Off Ver
    365
    Posts
    3

    Re: Using VBA to create a big table from two tables that reference each other - Too Slow

    Copy of System Design Tool - Rev 1 - Copy.xlsm

    Ive attached an example file for testing.

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

    Re: Using VBA to create a big table from two tables that reference each other - Too Slow

    try
    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. Dynamic Table Reference based on Todays Date to Create a Small Summary Table
    By Maxgrip27 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-27-2023, 11:43 AM
  2. [SOLVED] Create table from many tables at different sheets
    By adrianostlund in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-06-2023, 09:53 AM
  3. [SOLVED] cross-reference data from 2 tables to calculate a third table
    By bandtogether in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-21-2022, 09:23 AM
  4. [SOLVED] To create Table 2 with reference to Table 1 ... Which formula should I enter?
    By chief_abound in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-21-2018, 01:18 AM
  5. Using information from two tables to create a new table
    By London123 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-12-2017, 08:27 PM
  6. Create a tables with new name for each new table
    By JoeSkittles in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-15-2013, 03:17 PM
  7. Create one Table from Tables
    By easycapital in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-30-2008, 07:28 PM

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