hoangfe3o4
Thành viên mới
- Tham gia
- 12/8/14
- Bài viết
- 41
- Được thích
- 4
Các bác giúp em với:
Tình hình là e muốn đếm số ô màu vàng( được bôi tự động bằng conditional fomating) trong file excel và để nó hiển thị ở cột "Đếm số ô màu vàng"
Em tìm mãi được công thức này
Sub DisplayFormatCount()
'Updateby20150305
Dim Rng As Range
Dim CountRange As Range
Dim ColorRange As Range
Dim xBackColor As Long
Dim xFontColor As Long
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set CountRange = Application.Selection
Set CountRange = Application.InputBox("Count Range :", xTitleId, CountRange.Address, Type: = 8)
Set ColorRange = Application.InputBox("Color Range(single cell):", xTitleId, Type: = 8)
Set ColorRange = ColorRange.Range("A1")
xReturn = 0
For Each Rng In CountRange
qqq = Rng.Value
xxx = Rng.DisplayFormat.Interior.Color
If Rng.DisplayFormat.Interior.Color = ColorRange.DisplayFormat.Interior.Color Then
xBackColor = xBackColor + 1
End If
If Rng.DisplayFormat.Font.Color = ColorRange.DisplayFormat.Font.Color Then
xFontColor = xFontColor + 1
End If
Next
MsgBox "BackColor is " & xBackColor & Chr(10) & "FontColor is " & xFontColor
End Sub
Thì nó lại hiển thị ở box em nhờ các bác giúp e chuyển sang dạng Function để nó hiển thị trên file ở cột " Đếm số ô màu vàng"
Hay bác nào có cách nào hay chỉ e với ạ.
Em xin chân thành cảm ơn ạ.
Tình hình là e muốn đếm số ô màu vàng( được bôi tự động bằng conditional fomating) trong file excel và để nó hiển thị ở cột "Đếm số ô màu vàng"
Em tìm mãi được công thức này
Sub DisplayFormatCount()
'Updateby20150305
Dim Rng As Range
Dim CountRange As Range
Dim ColorRange As Range
Dim xBackColor As Long
Dim xFontColor As Long
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set CountRange = Application.Selection
Set CountRange = Application.InputBox("Count Range :", xTitleId, CountRange.Address, Type: = 8)
Set ColorRange = Application.InputBox("Color Range(single cell):", xTitleId, Type: = 8)
Set ColorRange = ColorRange.Range("A1")
xReturn = 0
For Each Rng In CountRange
qqq = Rng.Value
xxx = Rng.DisplayFormat.Interior.Color
If Rng.DisplayFormat.Interior.Color = ColorRange.DisplayFormat.Interior.Color Then
xBackColor = xBackColor + 1
End If
If Rng.DisplayFormat.Font.Color = ColorRange.DisplayFormat.Font.Color Then
xFontColor = xFontColor + 1
End If
Next
MsgBox "BackColor is " & xBackColor & Chr(10) & "FontColor is " & xFontColor
End Sub
Thì nó lại hiển thị ở box em nhờ các bác giúp e chuyển sang dạng Function để nó hiển thị trên file ở cột " Đếm số ô màu vàng"
Hay bác nào có cách nào hay chỉ e với ạ.
Em xin chân thành cảm ơn ạ.