+ Reply to Thread
Results 1 to 7 of 7

Combining strings in a range

  1. #1
    Registered User
    Join Date
    04-19-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    50

    Combining strings in a range

    I recently had a query about pulling data from different closed workbooks using a concatenate to easily choose the file:-
    http://www.excelforum.com/excel-gene...-workbook.html

    With some excellent advice from NVBC I was able to solve it, however I have since found that the time it takes to pull the data especially once it's more than around 1000 records is irritating my boss.

    I did some work on some VBA and came up with

    Please Login or Register  to view this content.
    Which works perfectly and virtually instantly, what I'm trying to do is find a way to make it do

    Please Login or Register  to view this content.
    Etc or more plainly

    A1 = B1 & C1 & D1
    A2 = B1 & C1 & D2
    A3 = B1 & C1 & D3
    A4 = B1 & C1 & D4
    A5 = B1 & C1 & D5

    Any ideas?
    Last edited by sigfreid; 09-16-2009 at 08:29 AM.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: Combining strings in a range

    Good morning sigfreid

    Assuming that your range takes up, say, A1:D10, and you want to concatenate B1, C1 and D1 in A1 ... and so on then the code below should work OK. You would need to highlight the range A1:A10 (the code takes from you which range to populate) and then run the macro.
    Please Login or Register  to view this content.
    HTH

    DominicB

    Edit : Please remember to use code tags next time you post examples of VBA. I have done it for you on this occasion.
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Combining strings in a range

    or maybe with no loops
    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  4. #4
    Registered User
    Join Date
    04-19-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: Combining strings in a range

    Sorry, always forget the tags lol, unfortunately I can't get either of these solutions to work, the first one returns the error usrcell is an undeclared variable and I don't know what to declare it as.

    The second just says type mismatch and gives no more information.

    I tried

    Please Login or Register  to view this content.
    which works,but it seems to create an endless loop and I thought

    Please Login or Register  to view this content.
    would fix that but it returns an error "Autofill method of range class failed"

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Combining strings in a range

    Hi sigfreid
    Place the codes in a module and run the macro code to see results

  6. #6
    Registered User
    Join Date
    04-19-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    50

    Re: Combining strings in a range

    ahaha *feels like a noob* I got yours to work Pike, it gave a "Autofill method of range class failed" at first but I only had to change

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    where xx is the last cell I want it to go to.

    I think that just about covers it, thanks to you both!

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Combining strings in a range

    I dont understand but any who ...can you please go to your first post select "edit" then "go advanced" and change the sufix to "solved"

+ 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