我想要:
- 循环遍历一个特定的列
H
(从H4
开始),并且 - 针对该列中的每个单元格,调用一个函数来查看它是否为真(然后执行某些操作),或者如果返回值为假(则执行其他操作)。
我在 Call Isletter
上得到了运行时错误 ***invalid use of property***
。
Sub IfBlank()
Dim Rng As Range
Dim MyCell As Range
Dim Isletter As Range
Set Rng = Range("H4:H" & Cells(Rows.Count, "H").End(xlUp).Row)
For Each MyCell In Rng
Call Isletter
If Isletter(MyCell.Value) = True Then
'do nothing
End If
If Isletter(MyCell.Value) = False Then
MyCell.Value = "-"
End If
Next MyCell
End Sub
Public Function IsLetter(MyCell As String) As Boolean
Dim intPos As Integer
For intPos = 1 To Len(MyCell)
Select Case Asc(Mid(MyCell, intPos, 1))
Case 33 To 127
Isletter = True
Case Else
Isletter = False
Exit For
End Select
Next
End Function
Fasle
应更正为False
。 - Mathieu GuindonCall Isletter
这一行,因为该函数已在if语句中调用,不再需要。 - Scott Craner