+ Reply to Thread
Results 1 to 8 of 8

Excel 2007 : Conditional formula

  1. #1
    Registered User
    Join Date
    03-10-2010
    Location
    Lebanon
    MS-Off Ver
    Excel 2007
    Posts
    4

    Conditional formula

    i need to do a condition that:

    if cell a=b=c=d then i want it to merge the 4 cells in 1 cell with the value of a
    and if not, to keep them as they are, how can i do it?
    help plz

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Conditional formula

    Hi Aizen, welcome to the forum.

    The following code checks to see if A1 = B1 = C1 = D1 and if so, merges and centers the cells. Whenever you merge cells, the default is to only keep the top & left-most cell data, so that's not an issue.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-10-2010
    Location
    Lebanon
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Conditional formula

    Hello Paul,
    thnx for the help, but unfortunately i didn't quite get how to do it, if you could please provide me with the writing way i would be grateful.
    like =if(....)
    Thnx in advance

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Conditional formula

    aizen, if you are asking whether this can be done with a worksheet formula, the answer is no.

    Paul, in the interest of avoiding merged cells and all the trouble they bring with them, I'd be interested to learn how the code would look with "center across selection" instead of merging.

    Care to indulge me?

  5. #5
    Registered User
    Join Date
    03-10-2010
    Location
    Lebanon
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Conditional formula

    Actually i have 4 cells containing letters, i want to make a condition that if these 4 cells have the same letters, then i want them to show me only 1 cell with the letters found, and if not the same letters then to leave them as they are

  6. #6
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Conditional formula

    You could do some tricking with conditional formatting

    If your values are in columns A, B, C, and D, select the cells from B1 to D100 (or whatever the last row of your range is, and create a conditional format - New Rule - Use a formula to determine... and enter this formula

    =AND($A1=$B1,$A1=$C1,$A1=$D1)

    Select a format where the text has the same color as the background (for example white text on white background), then the cell contents of these cells will become invisible.

    Is that a possibility?

  7. #7
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Conditional formula

    The code I provided earlier would work for letters or numbers. Below is a bit more proper code, and rather than merging A1:D1, it clears B1:D1 and then uses 'Center across selection' as merged cells can create problems down the road and are usually avoided if at all possible.

    Please Login or Register  to view this content.
    Place that in the worksheet module for Sheet1, put some values in A1 - D1 and test it out. If all four values match, the macro will run and should work as requested.

  8. #8
    Registered User
    Join Date
    03-10-2010
    Location
    Lebanon
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Conditional formula

    I'm sorry guys i didnt get it too, Paul about ur code where do i write it? in a cell or what
    any way here is a pic of what im planning to do, hope it helps
    \1

    im not that gd in programming stuff so i might need alot of help

    Edit: Ok i found out how to enter Paul's code, and I appreciate it, but if it is possible to be without macro it would be great
    anyway im working on the macro version hoping to see satisfying results
    Last edited by aizen92; 03-12-2010 at 04:08 PM.

+ 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