|
Private Sub CommandButton1_Click()
Dim i As Integer
Dim j As Integer
i = ActiveSheet.Cells(65536, ActiveSheet.UsedRange.Column).End(xlUp).Row
j = ActiveSheet.Cells(ActiveSheet.UsedRange.Row, 256).End(xlToLeft).Column
UsedRange.Select
If WorksheetFunction.CountIf(Range(Cells(1, 1), Cells(i, j)), Cells(1, 1)) > 1 Then
Selection.Font.ColorIndex = 3
End If
End Sub
本帖最后由 hwc2ycy 于 2012-8-24 00:16 编辑
- Private Sub CommandButton1_Click()
- Dim i As Integer
- Dim j As Integer
- Dim myrow&
- Dim mycol&
-
- Application.ScreenUpdating = False
- i = ActiveSheet.Cells(65536, ActiveSheet.UsedRange.Column).End(xlUp).Row
- j = ActiveSheet.Cells(ActiveSheet.UsedRange.Row, 256).End(xlToLeft).Column
- ActiveSheet.UsedRange.Font.ColorIndex = 0
- UsedRange.Select
- For myrow = ActiveSheet.UsedRange.Row To i
- For mycol = ActiveSheet.UsedRange.Column To j
- If WorksheetFunction.CountIf(Range(Cells(ActiveSheet.UsedRange.Row, ActiveSheet.UsedRange.Column), Cells(i, j)), Cells(myrow, mycol)) > 1 Then
- Cells(myrow, mycol).Font.ColorIndex = 3
- End If
- Next
- Next
- Application.ScreenUpdating = True
- End Sub
复制代码
|
-
|