我正在尝试有条件地格式化多个工作表中的单元格。范围的大小因每张纸而异(可能逐月变化)。每张纸都有一个标题,列数会有所不同,但是要格式化的数据总是从A6开始。
我成功选择了每个工作表中的最后一个单元格,并且成功格式化了每个工作表中的几个单元格。但是,当我尝试合并这些步骤时,我将失败。
Sub comfor()
Dim ws As Worksheet, LstR As Range
For Each ws In ActiveWorkbook.Sheets
Set LstR = ws.Range("A6").SpecialCells(xlLastCell)
For Each cell In LstR
If cell.Text = "Complete" Then
cell.Font.Color = 5287936
cell.Replace What:="Complete", Replacement:="R"
cell.Font.Name = "Wingdings 2"
End If
Next cell
Next ws
End Sub
谢谢!
答案 0 :(得分:0)
这样的东西(未经测试)
Sub comfor()
Dim ws As Worksheet, cell As Range
For Each ws In ActiveWorkbook.Sheets
For Each cell In ws.range(ws.range("A6"), _
ws.Range("A6").SpecialCells(xlLastCell)).cells
With cell
If .Text = "Complete" Then
.Font.Color = 5287936
.Value ="R"
.Font.Name = "Wingdings 2"
End If
End with
Next cell
Next ws
End Sub