我想做一个 If 语句来测量自动过滤列中的字符数量,如果字符数量 (Len) = 9 或 12,我希望它转到第一列并更改该行上单元格的名称到“克洛”。我希望它运行整个列(列 M 和 N)。我该怎么做呢?
Dim count As Integer, myRange As Range, rng As Range
Dim RealRng As Range
Set myRange = Columns("M:M")
count = Application.WorksheetFunction.CountA(myRange)
Set RealRng = ActiveSheet.Range("M2:M+" & count)
For Each rng In RealRng
If Len(rng) = 9 Or Len(rng) = 12 Then
rng.Offset(0, -12) = "Bond"
End If
Next rng