+ Reply to Thread
Results 1 to 9 of 9

VBA Collect Values Stored in Merged Cells into Array

  1. #1
    Registered User
    Join Date
    02-23-2014
    Location
    Christchurch, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    9

    Question VBA Collect Values Stored in Merged Cells into Array

    Hello All,

    I am a newbie to vba and the forum and hope to learn lots of new things from here.

    My first post is related to the collection of string values (which are names) from merged cells into an array which I wish to then pass on to another sheet.

    I have a sheet named "Cashbook" with the names commencing at row 20 of columns K:L (which are merged cells). This pattern is consistent across the entire sheet.

    I am wanting to collect the values in each of the cells from the start point to the end noting that the array will need to be dynamic as it grows as I enter data (currently 62 records / 124 columns). After doing so, I then want to transfer the data from the array into A2 on another sheet named "Selects"

    The only code I have so far is as follows:

    Please Login or Register  to view this content.
    I am wondering if someone can teach me how to achieve this?

    Thanks in advance.
    Last edited by fiasco; 02-24-2014 at 11:29 PM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Collect Values Stored in Merged Cells into Array

    Hello fiasco,

    Welcome to the Forum!

    This code example finds the number of rows used and copies the values to the other sheet. The code includes a method to list vertically (down the rows) and horizontally (across the columns).
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    02-23-2014
    Location
    Christchurch, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA Collect Values Stored in Merged Cells into Array

    Hi Leith.

    Thanks for the welcome plus the help on my question.

    In reviewing the answer you provided, I found that the code to be specific to rows whereas my question related to columns with merged cells.

    After doing some further research on Google, I have modified the code you provided (below) but cannot seem to get it to work the way I need.

    Please Login or Register  to view this content.
    If you could take another look at it I would be very grateful.

    Thanks
    Last edited by fiasco; 02-23-2014 at 10:32 PM.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Collect Values Stored in Merged Cells into Array

    Hello fiasco,

    Sorry, I am not following your logic. If you have a workbook you can post, it will help me follow what you want to do.

    How To Post Your Workbook
    1. At the bottom right of the Reply window, Click the button Go Advanced
    2. At the top of the Your Message Window, in the first row of icons, Click the Paperclip icon.
    3. Click the Add Files button at the top right in the dialog box. This displays the File Manager dialog.
    4. Click the Select Files button at the bottom middle of the dialog.
    5. In the new window Find the file you want to upload, select it, and Click Open.
    6. You will now be back in the File Manager dialog. Click the bottom Middle button Upload File.
    7. Wait until the file has completely uploaded before you exit the File Manager dialog.

  5. #5
    Registered User
    Join Date
    02-23-2014
    Location
    Christchurch, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA Collect Values Stored in Merged Cells into Array

    Hi Leith,

    Sure thing.

    Attached is a file with the data I want to collect in the "Cashbook" tab beginning in column K. I have pasted the results into the other tab "Selects" to show the desired output for you keeping in mind that the column count is dynamic and will continue to grow over time.

    Thanks again.
    F
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    02-23-2014
    Location
    Christchurch, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA Collect Values Stored in Merged Cells into Array

    Please help!! I have been wrecking my brain with this since yesterday!!

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Collect Values Stored in Merged Cells into Array

    Hello fiasco,

    This macro worked for me based on your sample . I have added it to the attached workbook.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    02-23-2014
    Location
    Christchurch, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA Collect Values Stored in Merged Cells into Array

    Dear Leith,

    Thanks for much for your reply and help with this question.

    I've tested and validated the code you provided and it works fine.

    Also added a couple of additional steps to the routine and which sorts the data a~z then adds the entire range as a drop down validation control on another worksheet.

    Much appreciated and thanks again.
    F

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Collect Values Stored in Merged Cells into Array

    Hello fiasco,

    You're welcome. Couldn't have done it without the workbook. thanks for posting it.

+ 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. Replies: 1
    Last Post: 06-28-2012, 11:53 AM
  2. [SOLVED] Indexing with merged cells in the Array
    By smls in forum Excel General
    Replies: 3
    Last Post: 05-21-2012, 10:15 AM
  3. Excel 2007 : Values for merged cells
    By carlscott in forum Excel General
    Replies: 2
    Last Post: 09-09-2011, 06:01 AM
  4. [SOLVED] SQL stored procedure using values from cells into Pivot Table
    By kworth in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-01-2006, 10:45 PM
  5. Solver with values not stored explicitly in cells
    By Stacy35216 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-17-2005, 08:55 PM

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