+ Reply to Thread
Results 1 to 26 of 26

How to combine two arrays into one, format and then write to a range?

  1. #1
    Registered User
    Join Date
    02-04-2021
    Location
    MA, USA
    MS-Off Ver
    2016
    Posts
    20

    How to combine two arrays into one, format and then write to a range?

    Hi, I have two arrays (two customer ID lists), which have empty ("") values and duplicate values. How do I combine the two arrays, remove the empty values and duplicate values into a new array and then write the values to a range? Thanks.

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

    Arrow Re: How to combine two arrays into one, format and then write to a range?


    Hi,

    an easy Excel beginner way if each list has a single column :
    • merge the lists to a single column
    • to copy the value to a range use an advanced filter on the merged column with the unique option to True …

  3. #3
    Registered User
    Join Date
    03-10-2021
    Location
    Paryzevo
    MS-Off Ver
    2k3
    Posts
    60

    Re: How to combine two arrays into one, format and then write to a range?

    Quote Originally Posted by Snowflakes2021 View Post
    I have two arrays
    Please attach some small sample data (xls file).

  4. #4
    Registered User
    Join Date
    02-04-2021
    Location
    MA, USA
    MS-Off Ver
    2016
    Posts
    20

    Re: How to combine two arrays into one, format and then write to a range?

    Thanks for the response. But I have to use VBA to do that... as it needs to be performed without manual operations.

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

    Arrow At kid level …


    As post #2 can be done under VBA so you can start operating manually with the Macro Recorder activated in order to get your own code …

  6. #6
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: How to combine two arrays into one, format and then write to a range?

    Hi
    ID list 1 in sheet1
    ID list 2 in sheet2
    result in sheet3
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    02-04-2021
    Location
    MA, USA
    MS-Off Ver
    2016
    Posts
    20

    Re: How to combine two arrays into one, format and then write to a range?

    I need to combine the cust ID in column A and D starting in row 5 into one list, for example, column A has cust ID 1,2,3,4,5,6; column D has 3,5,8,10

    Then remove the empty cell values and duplicates and then write the values into the next tab (e.g., column B starting in cell B6). I need to use VBA to avoid manual operations.

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

    Re: How to combine two arrays into one, format and then write to a range?

    Try
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-04-2021
    Location
    MA, USA
    MS-Off Ver
    2016
    Posts
    20

    Re: How to combine two arrays into one, format and then write to a range?

    I got syntax errors for the rows with "Transpose".

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

    Re: How to combine two arrays into one, format and then write to a range?

    How many rows do you have?
    If below doesn't work, I need to see your workbook.
    Please Login or Register  to view this content.
    Or
    Please Login or Register  to view this content.
    Last edited by jindon; 03-25-2021 at 09:23 AM.

  11. #11
    Registered User
    Join Date
    02-04-2021
    Location
    MA, USA
    MS-Off Ver
    2016
    Posts
    20

    Re: How to combine two arrays into one, format and then write to a range?

    It works, can you please add code to sort the values before write them into column B? I forgot to include this in my previous post. Thanks much!

  12. #12
    Registered User
    Join Date
    02-04-2021
    Location
    MA, USA
    MS-Off Ver
    2016
    Posts
    20

    Re: How to combine two arrays into one, format and then write to a range?

    Quote Originally Posted by jindon View Post
    Try
    Please Login or Register  to view this content.


    It works! I got syntax errors for the "Transpose" from another post, not from this one. Can you please add codes to sort the values before write them into column B? Thanks much.
    Last edited by Snowflakes2021; 03-25-2021 at 09:48 AM.

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

    Re: How to combine two arrays into one, format and then write to a range?

    Change to
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    02-04-2021
    Location
    MA, USA
    MS-Off Ver
    2016
    Posts
    20

    Re: How to combine two arrays into one, format and then write to a range?

    Quote Originally Posted by jindon View Post
    Change to
    Please Login or Register  to view this content.

    I got error 13: type mismatch...for With [b6].Resize(UBound(e) + 1)

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

    Re: How to combine two arrays into one, format and then write to a range?

    1)
    Please don't quote whole posts -- it's just clutter.*If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding

    2) I really need to see your workbook since the code was tested and working here before I post.

  16. #16
    Registered User
    Join Date
    02-04-2021
    Location
    MA, USA
    MS-Off Ver
    2016
    Posts
    20

    Re: How to combine two arrays into one, format and then write to a range?

    1) learning to post and will use best practice...(new user)
    2) how to attach workbook? (again very new user)

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

    Re: How to combine two arrays into one, format and then write to a range?

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  18. #18
    Registered User
    Join Date
    02-04-2021
    Location
    MA, USA
    MS-Off Ver
    2016
    Posts
    20

    Re: How to combine two arrays into one, format and then write to a range?

    Please see attached file. The "before" tab has two columns of data to be combined, duplicates and "" removed, sorted and then write to the "after" tab. The data in there is what's desired after the scripts are run. Thanks!
    Attached Files Attached Files

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

    Re: How to combine two arrays into one, format and then write to a range?

    So, different sheet.
    Alter sheet names to suite.
    Please Login or Register  to view this content.

  20. #20
    Registered User
    Join Date
    02-04-2021
    Location
    MA, USA
    MS-Off Ver
    2016
    Posts
    20

    Re: How to combine two arrays into one, format and then write to a range?

    awesome, this works! thanks much!

  21. #21
    Registered User
    Join Date
    03-10-2021
    Location
    Paryzevo
    MS-Off Ver
    2k3
    Posts
    60

    Re: How to combine two arrays into one, format and then write to a range?

    Another method:
    Please Login or Register  to view this content.
    Last edited by a2b1c1d1e1f1; 03-25-2021 at 07:31 PM.

  22. #22
    Registered User
    Join Date
    02-04-2021
    Location
    MA, USA
    MS-Off Ver
    2016
    Posts
    20

    Re: How to combine two arrays into one, format and then write to a range?

    Thank you for your response!

  23. #23
    Registered User
    Join Date
    02-04-2021
    Location
    MA, USA
    MS-Off Ver
    2016
    Posts
    20

    Re: How to combine two arrays into one, format and then write to a range?

    hi jindon, the macro (posted by you at 10:36 am 03-25) works perfectly for Form control (click button), but not working for activeX control, is there a solution? thanks!

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

    Re: How to combine two arrays into one, format and then write to a range?

    See attached.
    Attached Files Attached Files

  25. #25
    Registered User
    Join Date
    02-04-2021
    Location
    MA, USA
    MS-Off Ver
    2016
    Posts
    20

    Re: How to combine two arrays into one, format and then write to a range?

    thanks again!

  26. #26
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: How to combine two arrays into one, format and then write to a range?

    Well
    Same but...
    Attached Files Attached Files

+ 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] Combine two arrays into a third.
    By webwyzard in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-18-2018, 08:08 PM
  2. [SOLVED] Write Sub procedure to format excel and write case/if statement to text file
    By vbronton in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-06-2018, 08:26 AM
  3. [SOLVED] Combine two 1D arrays
    By billyjo182 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-25-2017, 11:28 AM
  4. VBA to Combine Spreadsheets using Arrays
    By batchjb69 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-06-2017, 02:29 PM
  5. Combine Arrays
    By kreitzig in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-04-2013, 02:31 PM
  6. Combine arrays
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-01-2011, 05:39 PM
  7. Compare Arrays write results to worksheet
    By jaslake in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-10-2010, 01:10 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