|
以下是引用Bluestone在2005-6-22 20:53:00的发言:
加班干活,要求在一个大SHEET 中用不同的颜色,标记不同性质的单元格,EXCEL 里,在正常模式单元格填充颜色无法看到,在打印预览下可以看到,这是怎么回事?
是不是在一张工作表中用不同颜色显示另一张工作表中单元格的性质啊?如果是这样的话,使用下面的宏。至于在正常模式不显示,我再想想
Sub ClrFormat()
If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub
On Error Resume Next
Set FormulaCells = Range("A1").SpecialCells _
(xlFormulas, xlNumbers + xlTextValues + xlLogical)
Set TextCells = Range("A1").SpecialCells(xlConstants, xlTextValues)
Set NumberCells = Range("A1").SpecialCells(xlConstants, xlNumbers)
On Error GoTo 0
'创建对象变量
Sheets.Add
'新增一个工作表用不同颜色显示活动工作表中单元格的不同格式
With Cells
.ColumnWidth = 2
.Font.Size = 8
.HorizontalAlignment = xlCenter
End With
Application.ScreenUpdating = False
If Not IsEmpty(FormulaCells) Then
'如果是公式,则显示为红色
For Each Area In FormulaCells.Areas
With ActiveSheet.Range(Area.Address)
.Interior.ColorIndex = 3
End With
Next Area
End If
If Not IsEmpty(TextCells) Then
'如果是文本,则显示为绿色
For Each Area In TextCells.Areas
With ActiveSheet.Range(Area.Address)
.Value = "T"
.Interior.ColorIndex = 4
End With
Next Area
End If
If Not IsEmpty(NumberCells) Then
'如果是数字,则显示为黄色
For Each Area In NumberCells.Areas
With ActiveSheet.Range(Area.Address)
.Value = "N"
.Interior.ColorIndex = 6
End With
Next Area
End If
End Sub
|
|