+ Reply to Thread
Results 1 to 3 of 3

auto merge adjacent cells into one if cell values are equal

  1. #1
    Registered User
    Join Date
    12-21-2011
    Location
    CALIFORNIA
    MS-Off Ver
    Excel 20010
    Posts
    1

    auto merge adjacent cells into one if cell values are equal

    Hello,

    I am extremely new to VBA and I understand that merging cells is a poor design, however, it needs to be done in my case.

    I am trying to create a macro that automatically merges two adjacent cells into one cell when both adjacent cells contain an equal value. Any help or guidance would be much appreciated.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: auto merge adjacent cells into one if cell values are equal

    It would be helpfull to have a sample workbook to work on. This way, we'll see where the data are and could come up with an effective macro to do this. Can you attach a workbook to this thread with some more details about which data to look at? It would be too long to scan all the cells in a sheet; we'dbetter to do this for a specific range of data only.
    Regards
    Pierre

  3. #3
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: auto merge adjacent cells into one if cell values are equal

    Try this code:
    Please Login or Register  to view this content.
    You can change the range the macro looks at by replacing "A1" by the address of the upper left cell of your data and do not forget to also change the number 1 in Cells(Rows.Count,1) portion of the code with the first column number of your data.
    Regards
    Pierre

+ 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