+ Reply to Thread
Results 1 to 4 of 4

Merge 4 cells into 1 depending on another cells value

  1. #1
    Registered User
    Join Date
    10-05-2011
    Location
    Essex, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    10

    Merge 4 cells into 1 depending on another cells value

    Good afternoon,

    I am looking for a way to merge 4 cells depending on a cell value. I will explain. I am creating a spreadsheet where I will be keeping track of peoples payments for a class. They can pay either weekly or monthly. for example:

    If A1 says "Monthly" I want B1:E1 to merge into one cell. If A1 says "Weekly" i want B1:E1 to be 4 separate cells. I am expecting this to be in vba and have a little experience but need a point in the right direction...


    Thank you in advance.

    Chris

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Merge 4 cells into 1 depending on another cells value

    I don't recommend the use of meregd cells for data sheets - most knowledgeable users avoid them as much as possible.
    It is better, IMO, to just leave the cells unmerged. You already flag the payment as weekly or monthly. Why the need to merge cells?

    However, give this code a try. It uses the worksheet change event to merge/unmerge cells in columns B:E when cells in column-A are changed to Monthly / Weekly.

    This code must go into the worksheet module: right click sheet tab > View Code > copy & paste code into the VB Editor then close it.
    If using Excel 2007 you must save to a .xlsm file type.

    Please Login or Register  to view this content.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Registered User
    Join Date
    10-05-2011
    Location
    Essex, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    10

    Re: Merge 4 cells into 1 depending on another cells value

    Thank you very much for your help. I totally understand what you mean about merging cells as I have already run into an issue!

    I am trying to populate the cells depending on the weekly/montly as well and am getting stuck. If weekly I want the range of cells to show 6 and of monthly I want the 1 to show 20. I have uploaded my sheet for you to look at if you /anyone can help me!

    Thank you!

    ChrisThrowdown.xls

  4. #4
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Merge 4 cells into 1 depending on another cells value

    hi crazytimechris, please check attachment, try to change D column values within D1:D19. The code works basing on the month name as a merged header. Changing value results in changes for all months for now.
    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)

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