Option Explicit
Sub ToMauFont0Values()
Dim Rng As Range, sRng As Range, Cls As Range
Dim MyAdd As String
Set Rng = [E8].CurrentRegion '<=| Chú Ý'
Set sRng = Rng.Find("0", , xlFormulas, xlWhole)
If Not sRng Is Nothing Then
MyAdd = sRng.Address
Do
If Cls Is Nothing Then
Set Cls = sRng
Else
Set Cls = Union(Cls, sRng)
End If
Set sRng = Rng.FindNext(sRng)
Loop While Not sRng Is Nothing And sRng.Address <> MyAdd
If Not Cls Is Nothing Then
Cls.Font.ColorIndex = 2
End If
End If
End Sub
PHP:Option Explicit Sub ToMauFont0Values() Dim Rng As Range, sRng As Range, Cls As Range Dim MyAdd As String Set Rng = [E8].CurrentRegion '<=| Chú Ý' Set sRng = Rng.Find("0", , xlFormulas, xlWhole) If Not sRng Is Nothing Then MyAdd = sRng.Address Do If Cls Is Nothing Then Set Cls = sRng Else Set Cls = Union(Cls, sRng) End If Set sRng = Rng.FindNext(sRng) Loop While Not sRng Is Nothing And sRng.Address <> MyAdd If Not Cls Is Nothing Then Cls.Font.ColorIndex = 2 End If End If End Sub
Em ví dụ nhỏ này em đã dùng CF thì thực hiện tốt. Nhưng em muốn dùng code để thay thế nó cho việc thực hiện khó hơn!
Vậy, nhờ các A/C xem dùm nhé!
Sub HideZero()
Range("E8:F19").NumberFormat = "#;;;@"
End Sub