- Joined
- 12/1/07
- Messages
- 22
- Points
- 11
Hi, :sos:
Any idea what can be wrong with this piece of code? I want to make the cell I am changing bold but it looks like it is looping and before I get my desired result it changes bold-not bold-bold-not bold for about like 20 times. I would appreciate some advice.
Private Sub Worksheet_Change(ByVal Target As Range)
S_Row = Target.Row
If IsEmpty(Cells(S_Row, 5)) Or IsEmpty(Cells(S_Row, 6)) Then Exit Sub
If Intersect(Target, Cells(S_Row, 5)) Is Nothing And Intersect(Target, Cells(S_Row, 6)) Is Nothing Then
Exit Sub
Else
If Intersect(Target, Cells(S_Row, 5)) Is Nothing Then
Cells(S_Row, 5) = Cells(S_Row, 6) * Cells(S_Row, 4)
Cells(S_Row, 6).Font.Bold = True
Cells(S_Row, 5).Font.Bold = False
Else
Cells(S_Row, 6) = Cells(S_Row, 5) / Cells(S_Row, 4)
Cells(S_Row, 5).Font.Bold = True
Cells(S_Row, 6).Font.Bold = False
End If
End If
End Sub
Any idea what can be wrong with this piece of code? I want to make the cell I am changing bold but it looks like it is looping and before I get my desired result it changes bold-not bold-bold-not bold for about like 20 times. I would appreciate some advice.
Private Sub Worksheet_Change(ByVal Target As Range)
S_Row = Target.Row
If IsEmpty(Cells(S_Row, 5)) Or IsEmpty(Cells(S_Row, 6)) Then Exit Sub
If Intersect(Target, Cells(S_Row, 5)) Is Nothing And Intersect(Target, Cells(S_Row, 6)) Is Nothing Then
Exit Sub
Else
If Intersect(Target, Cells(S_Row, 5)) Is Nothing Then
Cells(S_Row, 5) = Cells(S_Row, 6) * Cells(S_Row, 4)
Cells(S_Row, 6).Font.Bold = True
Cells(S_Row, 5).Font.Bold = False
Else
Cells(S_Row, 6) = Cells(S_Row, 5) / Cells(S_Row, 4)
Cells(S_Row, 5).Font.Bold = True
Cells(S_Row, 6).Font.Bold = False
End If
End If
End Sub