如果单元格值以 5 个空格开头,我会尝试将列 A 范围中的所有单元格加粗。目前这就是我正在尝试的;产生错误代码:
Run-time error '13': Type mismatch
Sub Bold ()
Set BoldRange = Sheets("Formatted Data").Range("A13:A100000")
If BoldRange.Value Like " *" Then
BoldRange.Font.Bold = True
End If
End Sub
注意,错误发生在
If BoldRange.Value Like " *" Then
行。不太确定我做错了什么?
如上所述,我已修改为使用 For...Next 循环。
Sub Bold ()
Dim rcell As Range, BoldRange As Range
Set BoldRange = Sheets("Formatted Data").Range("A13:A100000")
For Each rcell In BoldRange.Cells
If rcell.Value Like " *" Then rcell.Font.Bold = True
Next rcell
End Sub