我正在尝试对多个工作表中的单元格进行有条件的格式化。每个工作表的范围大小各不相同(也可能逐月变化)。每个工作表都有一个页眉和不同的列数,但要格式化的数据始终从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谢谢!
发布于 2019-04-17 05:54:54
类似这样的东西(未经测试)
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 Subhttps://stackoverflow.com/questions/55716944
复制相似问题