我正在尝试在VBA中编写一个Sub
的Range
:
Sub MarkCell(ByRef rng As Range, value As String)
For Each C In Range.Cells
If C = value Then
aCell.Interior.ColorIndex = 3
End If
Next C
End Sub
For
语句上出现“编译错误:参数不是可选的”。我想念什么?
最佳答案
您需要引用rng
参数。不是Range
类。
因此,如下所示修复您的代码。
For Each C In rng.Cells
If C = value Then
C.Interior.ColorIndex = 3
End If
Next C
https://stackoverflow.com/questions/26639878/