+ Reply to Thread
Results 1 to 15 of 15

How to write and concatenate multi elements from an array to a single cell on a worksheet

  1. #1
    Forum Contributor
    Join Date
    10-22-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    114

    How to write and concatenate multi elements from an array to a single cell on a worksheet

    Hi everyone,

    Any help or input would be greatly appreciated. This is the line that I have trouble with: Cells(i, 1) = Missing

    Result I am hoping for: 32, 35,49,76
    Concatenated with "," between the elements in array

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: How to write and concatenate multi elements from an array to a single cell on a worksh

    Please Login or Register  to view this content.
    Unless you need the Missing Array later, then Id remove it, Ive commented out the relevant lines in the code.
    If someone has helped you then please add to their Reputation

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to write and concatenate multi elements from an array to a single cell on a worksh

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    10-22-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: How to write and concatenate multi elements from an array to a single cell on a worksh

    pjwhitfield - Thank you for your help. Your code works great. I originally put the missing string as an array because it was running really slow, but for some reason, you code doesn't have that problem. Thanks again.

  5. #5
    Forum Contributor
    Join Date
    10-22-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: How to write and concatenate multi elements from an array to a single cell on a worksh

    AB33 - Appreciate your help. Can you explain this line of code Cells(i, 1) = Mid(Temp, 2) and how you delete the first comma? Also, the Mid function requires 3 criteria, but in your Mid function you only have 2.
    Last edited by Xceller; 11-25-2014 at 08:06 PM.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Lightbulb Re: How to write and concatenate multi elements from an array to a single cell on a worksh


    Hi !

    Another way with a single dimension array is to use Join function :

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-22-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: How to write and concatenate multi elements from an array to a single cell on a worksh

    MarcL - Thanks for your recommendation. I put the Join function in the Array and it still doesn't work.

    This is what I did: Cells(i,1) = Join(Missing, ", ")

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to write and concatenate multi elements from an array to a single cell on a worksh

    Where is the word "Missing" in the output you posted?
    Just add the word and change this line.

    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Exclamation Re: How to write and concatenate multi elements from an array to a single cell on a worksh


    Quote Originally Posted by Xceller View Post
    I put the Join function in the Array and it still doesn't work.

    This is what I did: Cells(i,1) = Join(Missing, ", ")
    As I yet wrote, Join function works only with a one dimension array variable …

  10. #10
    Forum Contributor
    Join Date
    10-22-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: How to write and concatenate multi elements from an array to a single cell on a worksh

    AB33 - Appreciate your help. Can you explain this line of code Cells(i, 1) = Mid(Temp, 2) and how you delete the first comma? Also, the Mid function requires 3 criteria, but in your Mid function you only have 2.

  11. #11
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to write and concatenate multi elements from an array to a single cell on a worksh

    My code is the same as pjwhitfield's code. Your output shows a comma too.

  12. #12
    Forum Contributor
    Join Date
    10-22-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: How to write and concatenate multi elements from an array to a single cell on a worksh

    Temp=,32,35,49,76
    Mid(Temp,2)=32,35,49,76

    My under standing of the MID function is MID(Text, Start_Num, Num_Char)
    So in your Mid function, Temp is the Textstring, the 2 means Num_Char 2? How about the 2nd criterion Start_Num?

  13. #13
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to write and concatenate multi elements from an array to a single cell on a worksh

    Please Login or Register  to view this content.
    "My choice" could be any number from 1 to unknown. In your case, we want to return-starting from 2 and number of return is unknown, or entire text.
    I hope you got it now.

  14. #14
    Forum Contributor
    Join Date
    10-22-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: How to write and concatenate multi elements from an array to a single cell on a worksh

    @AB33 - Thanks again for the explanation. Crystal clear. You are awesome! Have a great Thanksgiving!

  15. #15
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to write and concatenate multi elements from an array to a single cell on a worksh

    You are welcome and have a great one too!

+ 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] Removing specific elements from an Array based on matching elements in a different Array
    By jamesdeuce in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-24-2014, 10:35 PM
  2. help assigning elements of dictionary to array and then pasting array into worksheet
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-05-2013, 10:37 AM
  3. multiple string dates in cell, to array, and manipulate single elements
    By willara23 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-18-2013, 07:48 PM
  4. [SOLVED] Populate Listbox with all rows of a dynamic array where elements of a single array match.
    By Tayque_J_Holmes in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 08-07-2012, 04:54 AM
  5. Single Conditional Array x two Multi-Column Array - Approach needed
    By David Brown in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-28-2010, 11:41 AM

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