在Excel VBA中编译错误
我已经开发了VBA代码来在Excel中search特定的电子邮件types(例如。@ gmail.com)。 它会将下一个单元格标记为符合条件的“TRUE”。
我在while循环中遇到了编译错误
Dim c As Range Dim SrchRng Dim myarray As Variant myarray = Array("@email.com","@gmail.com") Set SrchRng = ActiveSheet.UsedRange for each emailarray in myarray Do Set c = SrchRng.Find("emailarray", LookIn:=xlValues) If Not c Is Nothing Then 'c.EntireRow.Delete row_num = Split(c.Address(ColumnAbsolute:=False, RowAbsolute:=False), "A") Range("C" & row_num(1)).Value = "True" Loop While Not c Is Nothing next emailarray
你的失踪和End If
而且你也有Do ... Loop While
当它看起来应该是你的情况
Do While .... Loop
要么
Do Until ... Loop
请添加一个end if
你的代码。
If Not c Is Nothing Then 'c.EntireRow.Delete row_num = Split(c.Address(ColumnAbsolute:=False, RowAbsolute:=False), "A") Range("C" & row_num(1)).Value = "True" End If