+ Reply to Thread
Results 1 to 4 of 4

four cells, constitute one, two, three or four cells, depending on value

  1. #1
    Registered User
    Join Date
    07-10-2018
    Location
    Denmark
    MS-Off Ver
    2017
    Posts
    8

    Question four cells, constitute one, two, three or four cells, depending on value

    Hi
    Happy New Year to everyone.
    I have a question and don't know if it can be done, that's why I try keeping it simple!

    I have a sheet1, on this I have four cells:
    2A, 2B, 2C and 2D, these four cells have a total width of 40 pixels.

    Then I have a sheet2 where I also have four cells again:
    2A, 2B, 2C and 2D, these cells may content a character "x".

    - For example,if on sheet 2 there is an "X" in either 2A, 2B, 2C or 2C, then I want the 4 cells on sheet1 to be merged into one 40pixel cell and given the background color "green".
    - On the other hand, if there is 2 "X" on my sheet2, in a combination of 2A, 2B, 2C or 2C, then I want the 4 cells on sheet1 to be merged into two cells (ie 2A + 2B and 2C + 2D) so they both become 20px wide and have a total width of 40pixel and get background color "green" and "blue" respectively.
    - And if I for example in sheet2 have three "X" in 2A, 2B, 2C or 2D (ie 3 out of the 4 possible) then I want the 4 cells on sheet1 to be merged so that 2B and 2C are merged and that 2A, 2B + 2C, as well as 2D, have a width of 13 pixels, so they have a total width of 39pixels and get background colors "green", "blue" and "red" respectively.
    - And lastly, if there is an "X" in all of the four cells (2A, 2B, 2C and 2D) then no cells should be changed and stained with "green", "blue", "red" and "yellow" color, each.

    Hope it has not become too complicated and that it can be done, I can fine-tune the cells, but do not know exactly how to access the function, so based on the number of "X" is on my sheet2, can merge the cells on sheet1 to 1 or 2 and give these colors, or merge 2B and 2C, where the "three" cells on sheet1 then become of equal width and become filled with 3 colors.

    about the four "X" is, then I think I can, because there is no change of the cells on sheet1, it is a question that if 2A on sheet2 has an "X" then 2A on sheet1 have the color "Green".

    Can some guide / help me on the right path :-)

    In advance thank you!

  2. #2
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: four cells, constitute one, two, three or four cells, depending on value

    ThomasBP, there is no worksheet function that can merge cell. There could be trick with UDF but I think you need format range of cells but small example can explain more.
    Post a small Excel sheet (not a picture) showing realistic & representative sample data WITHOUT confidential information (10-20 rows, not thousands...) and some manually calculated results.

  3. #3
    Registered User
    Join Date
    07-10-2018
    Location
    Denmark
    MS-Off Ver
    2017
    Posts
    8

    Re: four cells, constitute one, two, three or four cells, depending on value

    Hi BMV

    I have been looking around and can see that I can handle it with some VBA, I have tried to make a VBA so that if three out of my four cells on sheet2 (A2, B2, C2 and D2) have an "X", then I want my sub "4Cells2_3" function to be activated and if there are 2 of the fields that have an "X" then it is my sub "4Cells2_2" function that gets activated on my sheet1.

    My SUB function is the following, my question is just how can I activate my function?

    Please Login or Register  to view this content.

  4. #4
    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,780

    Re: four cells, constitute one, two, three or four cells, depending on value

    This thread is now in the VBA section.
    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.

+ 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. [SOLVED] Selecting cells in next/previous column depending on current selected cells
    By Skeidser in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-27-2018, 06:20 AM
  2. Replies: 1
    Last Post: 09-06-2018, 03:31 AM
  3. Replies: 5
    Last Post: 04-13-2018, 03:29 PM
  4. Copy and paste specific cells depending on adjacent cells HELP NEEDED
    By clacheson1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-20-2017, 04:06 PM
  5. Formula checks multiple cells for words and outputs answer depending on cells
    By keez1993 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-15-2015, 09:18 AM
  6. Replies: 2
    Last Post: 05-14-2015, 03:19 PM
  7. [SOLVED] Priority Rank depending on blank cells w/ bypassing cells with content
    By eaflynn in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-26-2015, 01:30 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