mahadeshwar
05-11-2006, 04:26 AM
Hi please can you help
i have got some brilliant code from one of your posts it is for conditonal formatting
But it formats all the cells in a spreadsheet. How do i specify it to only format cells in the F coloun of the excel spreadsheet
see below
Many Thanks
Jai
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
Dim Rng1 As Range
On Error Resume Next
Set Rng1 = ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas, 1)
On Error GoTo 0
If Rng1 Is Nothing Then
Set Rng1 = Range(Target.Address)
Else
Set Rng1 = Union(Range(Target.Address), Rng1)
End If
For Each Cell In Rng1
Select Case Cell.Value
Case vbNullString
Cell.Interior.ColorIndex = xlNone
Cell.Font.Bold = False
Case 1 To 5
Cell.Interior.ColorIndex = 5
Cell.Font.Bold = True
Case 16 To 25
Cell.Interior.ColorIndex = 3
Cell.Font.Bold = True
Case 11 To 15
Cell.Interior.ColorIndex = 7
Cell.Font.Bold = True
Case Else
Cell.Interior.ColorIndex = xlNone
Cell.Font.Bold = False
End Select
Next
End Sub
i have got some brilliant code from one of your posts it is for conditonal formatting
But it formats all the cells in a spreadsheet. How do i specify it to only format cells in the F coloun of the excel spreadsheet
see below
Many Thanks
Jai
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
Dim Rng1 As Range
On Error Resume Next
Set Rng1 = ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas, 1)
On Error GoTo 0
If Rng1 Is Nothing Then
Set Rng1 = Range(Target.Address)
Else
Set Rng1 = Union(Range(Target.Address), Rng1)
End If
For Each Cell In Rng1
Select Case Cell.Value
Case vbNullString
Cell.Interior.ColorIndex = xlNone
Cell.Font.Bold = False
Case 1 To 5
Cell.Interior.ColorIndex = 5
Cell.Font.Bold = True
Case 16 To 25
Cell.Interior.ColorIndex = 3
Cell.Font.Bold = True
Case 11 To 15
Cell.Interior.ColorIndex = 7
Cell.Font.Bold = True
Case Else
Cell.Interior.ColorIndex = xlNone
Cell.Font.Bold = False
End Select
Next
End Sub