+ Reply to Thread
Results 1 to 4 of 4

Merge/unmerge based on whether specific text is present in a column

  1. #1
    Registered User
    Join Date
    09-11-2012
    Location
    West Virginia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Merge/unmerge based on whether specific text is present in a column

    This should be simple - I have seen a similar post, but I do not have the skills to pull from their examples to fix my solution despite a full day of code tweaking.

    I am trying to write a loop code that will merge cells (in columns B, C, D and E) for that row depending on whether a specific word is present in column A.

    For example: If the word "Table" is present in Cell A15, no cells are merged in row 15- and not for the next three rows either (rows 16-18). If the word is not present in the particular row of Column A, then row cells of columns B:E are merged except for when the row follows as above for the word "Table".

    I attached a simplified spreadsheet with an example expected outcome. In my real data table, the values of cells in Column A are referencing data in a different sheet, and upated often, so the code needs to be able to update (merge/unmerge) depending on every change.

    Thank you greatly,
    Susan
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    09-11-2012
    Location
    West Virginia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Merge/unmerge based on whether specific text is present in a column

    Here is what I have thus far, but I cannot figure out a quicker way to do this, or any way to select the next few rows after the word "Table" appears and keep them also unmerged. Any suggestions?

    HTML Code: 
    I should also mention that I really need this as VBA (I cannot hard code the spreadsheet cells as the values are ever changing) and I need to word wrap and left justify the contents that will be placed into the merged cels. The merged cells take up the same space as the table, so everything is neat and tidy when the data is pasted into a different document. If there is a better way to maintain formatting, please advise.
    Last edited by susanbarbour; 09-25-2012 at 01:18 AM.

  3. #3
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Merge/unmerge based on whether specific text is present in a column

    PL see the atached file with macro "Merge".
    If it is ok, mark the thread SOLVED.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    09-11-2012
    Location
    West Virginia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Merge/unmerge based on whether specific text is present in a column

    Thank you, I moved the macro to the sheet to activate when the sheet opened, and that did the trick!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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