+ Reply to Thread
Results 1 to 8 of 8

Increasing the Speed of Concatenation

  1. #1
    Registered User
    Join Date
    08-15-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    16

    Increasing the Speed of Concatenation

    Hello All,

    First of all, this is my first post so if there is anything I'm doing wrong, do let me know. I had a long look through the forums and found nothing specific on the topic of concatenation speed.

    Some background:
    I import web data into an area roughly 20 columns wide and 2000 rows tall. In order for this data to be analyzed, each column (B to T) must have its value appended to the value of A. This of course is repeated for the 2000 rows.

    Conceptually, I want the value of A1 to equal A1 & B1 & C1 ... & T1. A2 should equal A2 & B2 & C2 ... & T2. And so on. The relevant VB Code that I have been using to do this is:

    Please Login or Register  to view this content.
    The issue is that this code takes about 20 seconds to run. (This occurs about 500 times in my project!) Are there any faster methods for concatenating the contents of multiple cells?

    Thanks in advance!
    Last edited by JBeaucaire; 08-15-2013 at 09:31 AM. Reason: Added CODE tags, as per Forum Rules. Take a moment to read the Forum Rules in the menu bar above. Thanks.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Increasing the Speed of Concatenation

    This seems faster than 20 seconds.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Increasing the Speed of Concatenation

    hi tung74, welcome to Excelforum, without seeing the actual data that might limit number of methods can be used, please check attachment, press Run button or run code "test"
    Attached Files Attached Files

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Increasing the Speed of Concatenation

    This should do it in less than a second, no looping at all:

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 08-15-2013 at 09:40 AM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    08-15-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Increasing the Speed of Concatenation

    Thanks for the reply Norie. I'm getting a type mismatch error on the first line inside the for next loop. I think it may be to do with the way you declared the array? I'm no expert though.

    watersev and JBeaucaire: it looks like both of your methods work perfectly, though JBeaucaire's does it without adding spaces between each value (easy fix).

    I dumbed down my original explanation a bit. Would it be possible to do that exact process but only for rows below A20? I'm not familiar with the "xl" script you both used and I'm getting errors when I try to change it myself. (Apologies for what's probably a silly question)

    Thank you SO much!

  6. #6
    Registered User
    Join Date
    08-15-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Increasing the Speed of Concatenation

    To clarify, I want to leave rows 1 to 19 unmodified while the macro runs.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Increasing the Speed of Concatenation

    The error you describe could be to do with the data, it's unlikely to be with the declarations.

  8. #8
    Registered User
    Join Date
    08-15-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Increasing the Speed of Concatenation

    For any future reader, this is how I ended up concatenating 78 columns into Column A for Rows 20 to 2000

    Thanks again to Norie, watersev, and JBeaucaire for the help!

    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. [SOLVED] Increasing code speed by computer upgrade?
    By Imperial in forum Excel General
    Replies: 13
    Last Post: 06-22-2013, 02:58 PM
  2. [SOLVED] Need to improve speed of concatenation macro
    By engineerlady in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-01-2013, 11:19 AM
  3. Increasing excel speed
    By galvinpaddy in forum Excel General
    Replies: 2
    Last Post: 11-05-2012, 04:11 PM
  4. Increasing File Opening Speed for Large Shared Files
    By petevang in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-03-2010, 10:13 PM
  5. Increasing Processing Speed
    By boylejob in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-11-2008, 02:19 AM

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