+ Reply to Thread
Results 1 to 7 of 7

Multiple condition formatting

  1. #1
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Multiple condition formatting

    Hi.. got a simple question here...
    I need to change the cells in a column but with multiple conditions e.g :

    Please Login or Register  to view this content.
    Into

    Please Login or Register  to view this content.
    Or in select case function it would look like this (sort of) :

    Please Login or Register  to view this content.
    Ive been trying to do this but can;t seem to get it to work ..

    Please Login or Register  to view this content.


    Could anyone fix it for me? It should be very simple for you guys...
    thanks.
    Last edited by Kb24; 09-10-2009 at 08:51 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Multiple condition formatting

    Try this:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    09-10-2009
    Location
    Altrincham, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Multiple condition formatting

    Hi Kb24,

    Try this, if I understand you the idea is your trying to switch around two numbers based on the value of the first...

    The example will switch all number 3s in the range with the number 6, expand upon this yourself by copying the 'case' and the line below it replacing the values to find and replace.

    PHP Code: 
    Sub ChangeValues()

    Dim Beta As Range
    Dim cell 
    As Range

    Set Beta 
    Range("A1:A7")

        For 
    Each cell In Beta

        Select 
    Case cell.Value

                  
    Case 3

                  cell
    .Value 6

        End Select

        Next

    End Sub 
    Drew

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Multiple condition formatting

    Your If statement is looking for "004", etc. I would think that the zeros don't exist, they are put there by Formatting so nothing would be found.

    The Select case is much neater
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Multiple condition formatting

    Thanks!
    Just one more thing :

    How do we state that if the condition is not met,
    the specific cell remain unchanged?

    Please Login or Register  to view this content.
    e.g if there is 67 in column A1, then the cell remains as 67 because 67 is not in the case-select conditions


    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    result

    Please Login or Register  to view this content.
    Last edited by Kb24; 09-10-2009 at 07:33 AM.

  6. #6
    Registered User
    Join Date
    09-10-2009
    Location
    Altrincham, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Multiple condition formatting

    The case else stament is not needed if you do not wish the statement to do something in the event of a match not being found,

    However if you wish to tack it on just to make the select statement look complete just leaving it as;

    Case 3: cell = "'0006"
    Case else:

  7. #7
    Registered User
    Join Date
    05-08-2009
    Location
    Yogya
    MS-Off Ver
    Excel 2007
    Posts
    96

    Re: Multiple condition formatting

    Thanks alot!
    This forum always deliver :D

+ 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