+ Reply to Thread
Results 1 to 15 of 15

Merging cells in a column to represent the value of another column

  1. #1
    Registered User
    Join Date
    04-10-2017
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    9

    Merging cells in a column to represent the value of another column

    Hello wonderful peoples,

    I am having trouble to implement something. Basically what I am doing is creating a layout. From the dropdown menu, I have different options in column B, and these options have different sizes, as found in column E.The data from the dropdown is automatically pulled from another tab in the same sheet. What I want now is when the value of column E is X, i want X cells in column B to be automatically merged. For example suppose if I choose cell B30, and the value in E30=2, I want cells B29 and B30 to merge together. Is it possible to do it with a formula (IF statement) or need to write a vba code (I am quite poor at writing codes). Thank you in advance for your help.
    excel.jpg

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,889

    Re: Merging cells in a column to represent the value of another column

    Welcome to the forum!

    Will you please attach a sample Excel workbook? We are not able to work with or manipulate a picture of one.

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    04-10-2017
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    9

    Re: Merging cells in a column to represent the value of another column

    I have attached a sample of the workbook I want to modify. As seen from the desired output picture, when selecting from the dropdown, I want the cells to merge according to the U number. For example if I select Y from the dropdown on cell 30, the U=4. So I want cells 27-30 to merge.
    Thanks.
    Attached Images Attached Images
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-10-2017
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    9

    Re: Merging cells in a column to represent the value of another column

    Anyone to help?

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

    Cool Re: Merging cells in a column to represent the value of another column


    Hi !

    Try this demonstration :

    PHP Code: 
    Sub Demo4Evil()
             
    Dim Rg As Range
        
    For Each Rg In ActiveSheet.UsedRange.Columns(5).SpecialCells(xlCellTypeFormulasxlNumbers)
              If 
    Rg.Value 1 Then Rg(Rg.Value, -2).Resize(Rg.Value).Merge
        Next
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  6. #6
    Registered User
    Join Date
    04-10-2017
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    9

    Re: Merging cells in a column to represent the value of another column

    doesn't work

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Merging cells in a column to represent the value of another column

    Hi tabascorez,

    Excel should never have invented "merged cells". Can you accomplish your goal without using them? Us Excel Guru's think Merged cells leads to more problems than they fix.

    Why don't you repeat the Chassis letter all the way down column B? That way you could filter by each Chassis.
    Last edited by MarvinP; 04-19-2017 at 11:43 PM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  8. #8
    Registered User
    Join Date
    04-10-2017
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    9

    Re: Merging cells in a column to represent the value of another column

    Hi, it is imperative that I merge these cells because the value in column E represents the size of the chassis

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

    Question Re: Merging cells in a column to represent the value of another column

    Quote Originally Posted by tabascorez View Post
    doesn't work
    As my code rocks on my side with your attachment ‼

  10. #10
    Registered User
    Join Date
    04-10-2017
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    9

    Re: Merging cells in a column to represent the value of another column

    can you repost the attachment with your code?

  11. #11
    Registered User
    Join Date
    04-10-2017
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    9

    Re: Merging cells in a column to represent the value of another column

    OK, I got the macro to run, but I have to run it each time when I make a change. Is there a way to make it run automatically when I change from the drop-down?

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

    Re: Merging cells in a column to represent the value of another column


    So Use Worksheet_Change event within worksheet module …

  13. #13
    Registered User
    Join Date
    04-10-2017
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    9

    Re: Merging cells in a column to represent the value of another column

    do you mean this step?
    Copy the code that you want to use
    Select the worksheet in which you the code to run
    Right click on the sheet tab and click View Code, to open the Visual Basic Editor.

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

    Re: Merging cells in a column to represent the value of another column


    Yes paste the code into worksheet module within Worksheet_Change procedure …

  15. #15
    Registered User
    Join Date
    04-10-2017
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    9

    Re: Merging cells in a column to represent the value of another column

    Hi Marc, sorry for late reply,was super busy. I tried to run it as you mentioned, but no good results

+ 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. Merging Multiple Sheet's column of data based on other column's cell value
    By BALA1983 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2017, 12:32 AM
  2. Count instances and represent in a column
    By elmnas in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-26-2015, 06:02 AM
  3. [SOLVED] Merging cells in specific multiple columns where column A values are the same
    By badlydrunkboy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2014, 07:54 AM
  4. [SOLVED] Merging cells to quickly add information to entire column
    By Erik Thomas in forum Excel General
    Replies: 2
    Last Post: 11-13-2012, 02:34 PM
  5. Using R1C1 to represent a entire column in VBA formulaArray
    By Lifeseeker in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 01-18-2012, 02:22 PM
  6. merging cells prohibits slanting column line?
    By wh3resmycar in forum Excel General
    Replies: 3
    Last Post: 08-04-2010, 08:47 AM
  7. how to use the variable to represent the column
    By yjmmay34 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-02-2010, 03:56 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