dangky47h
Thành viên thường trực
![](/diendan/data/PhoToDanhHieu/gold.gif)
![](/diendan/data/PhoToDanhHieu/gold.gif)
![](/diendan/data/PhoToDanhHieu/gold.gif)
![](/diendan/data/PhoToDanhHieu/gold.gif)
- Tham gia
- 4/9/17
- Bài viết
- 341
- Được thích
- 41
- Giới tính
- Nam
https://www.techonthenet.com/excel/questions/cond_format3.phpE cám ơn, Cho e hỏi có cách nào chỉ tô màu 02 giá trị lơn nhất và nhỏ nhất không ạ!
Bạn tham khảo thử cái này xemHi, Anh giúp em tạo code bài này với ạ!
Sub Tim_Min_Max()
Dim sRng As Range, Cll As Range
Dim Nhonhat As Double, Lonnhat As Double, I As Long
On Error GoTo Thoat
Set sRng = Application.InputBox(Prompt:="chon vung du lieu ", Title:="Chon du lieu dau vao", Type:=8)
Nhonhat = Application.Min(sRng)
Lonnhat = Application.Max(sRng)
sRng.Interior.Pattern = xlNone
For Each Cll In sRng
If Cll.Value = Nhonhat Then Cll.Interior.Color = 65535
If Cll.Value = Lonnhat Then Cll.Interior.Color = 5287936
Next
Thoat:
End Sub
E cám ơn, đúng ý Em rồi. Chúc Chị buổi tối vui vẻ!Bạn tham khảo thử cái này xem
PHP:Sub Tim_Min_Max() Dim sRng As Range, Cll As Range Dim Nhonhat As Double, Lonnhat As Double, I As Long On Error GoTo Thoat Set sRng = Application.InputBox(Prompt:="chon vung du lieu ", Title:="Chon du lieu dau vao", Type:=8) Nhonhat = Application.Min(sRng) Lonnhat = Application.Max(sRng) sRng.Interior.Pattern = xlNone For Each Cll In sRng If Cll.Value = Nhonhat Then Cll.Interior.Color = 65535 If Cll.Value = Lonnhat Then Cll.Interior.Color = 5287936 Next Thoat: End Sub
Sub CucTri()
Dim Max_ As Double, Min_ As Double
Dim Rng As Range, sRng As Range, WF As Object
Set WF = Application.WorksheetFunction
Set Rng = [a1].Resize([a1].CurrentRegion.Rows.Count)
Max_ = WF.Max(Rng): Min_ = WF.Min(Rng)
Set sRng = Rng.Find(Max_, , xlFormulas, xlWhole)
If Not sRng Is Nothing Then
sRng.Interior.ColorIndex = 38
End If
Set sRng = Rng.Find(Min_)
If Not sRng Is Nothing Then
sRng.Interior.ColorIndex = 35
End If
Set Rng = Rng.Offset(, 1)
Rng.NumberFormat = "mm/dd/yyyy"
Max_ = WF.Max(Rng): Min_ = WF.Min(Rng)
Set sRng = Rng.Find(Format(Max_, "mm/dd/yyyy"), , xlValues, xlWhole)
If Not sRng Is Nothing Then
sRng.Interior.ColorIndex = 39
End If
Set sRng = Rng.Find(Format(Min_, "mm/dd/yyyy"))
If Not sRng Is Nothing Then
sRng.Interior.ColorIndex = 36
End If
End Sub
E cám ơn ThầyPHP:Sub CucTri() Dim Max_ As Double, Min_ As Double Dim Rng As Range, sRng As Range, WF As Object Set WF = Application.WorksheetFunction Set Rng = [a1].Resize([a1].CurrentRegion.Rows.Count) Max_ = WF.Max(Rng): Min_ = WF.Min(Rng) Set sRng = Rng.Find(Max_, , xlFormulas, xlWhole) If Not sRng Is Nothing Then sRng.Interior.ColorIndex = 38 End If Set sRng = Rng.Find(Min_) If Not sRng Is Nothing Then sRng.Interior.ColorIndex = 35 End If Set Rng = Rng.Offset(, 1) Rng.NumberFormat = "mm/dd/yyyy" Max_ = WF.Max(Rng): Min_ = WF.Min(Rng) Set sRng = Rng.Find(Format(Max_, "mm/dd/yyyy"), , xlValues, xlWhole) If Not sRng Is Nothing Then sRng.Interior.ColorIndex = 39 End If Set sRng = Rng.Find(Format(Min_, "mm/dd/yyyy")) If Not sRng Is Nothing Then sRng.Interior.ColorIndex = 36 End If End Sub