• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Change the data properties using condition statement.

sampath

Member
Hello,

I have ennumber of data, which data file was attached here.

In that file, I need to change the data properties based on condition.

Required Coding.

If there is no data in cell(empty), that cell was changed in blue color.

If any cell having 7 and above, that cell was changed in red color and that number properties changed in "bold" with "italic".

Kindly provide the macro coding for the above requirements.

Regards,
Sampath.S
 

Attachments

Hello Nebu,

I need macro coding for that, because i attached that code into another macro.

Kindly provide the VB coding for that.

Regards,
Sampath
 
Hi:

Use the following code, change the range as per your need and call the macro in any of the worksheet event.
Code:
Sub CellFormat()
Application.ScreenUpdating = False
Dim rng As Range
Dim c As Range

Set rng = Sheet1.Range("B2:F7")

For Each c In rng
    If c.Value = vbNullString Then
        c.Interior.ColorIndex = 32
    ElseIf c.Value >= 7 Then
        c.Interior.ColorIndex = 3
        c.Font.Bold = True
        c.Font.Italic = True
    Else
    c.Interior.ColorIndex = 2
    End If
Next
Application.ScreenUpdating = True
End Sub

Thanks
 
Back
Top