Results 1 to 5 of 5

Thread: Conditional Formatting

  1. #1

    Conditional Formatting



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hello

    I need VB code for conditional formatting for following criteria

    if the cell value in column b is grater than cell value in column a, cell in column should b should turn in to green, if it is lesser than it should turn in to red, and if its equal no change.

    i know this can be resolved with conditional formatting option in excel, but in that case i have to apply on each cell one by one.

    my data base is too big, so i want solution with VB codes.

    Thanks a ton

  2. #2
    You don't have to apply to each one separately, just select the whole range, and use a formula that applies to the first in the selection. Excel will handle the automatic adjustment.

  3. #3
    Thanks Bob.. its working now.. but if possible can you please provide vb codes also..

  4. #4
    I would so the same in VBA

    Code:
        With Range("B2:B5")    
            For i = .FormatConditions.Count To 1 Step -1
            
                .FormatConditions(i).Delete
            Next i
            
            .FormatConditions.Add Type:=xlExpression, Formula1:="=B2>A2"
            With .FormatConditions(1)
            
                .Interior.ColorIndex = 35
            End With
        End With
    Last edited by Bob Phillips; 2014-06-14 at 12:02 PM.

  5. #5
    Quote Originally Posted by canischintsomani View Post
    Thanks Bob.. its working now.. but if possible can you please provide vb codes also..
    Thanks for the tip mate.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •