0

I have developed VBA code to search the particular email type (for example [email protected]) in Excel. It will mark the next cell as a "TRUE" which is matched by condition.

I got compile error in do while loop

compile time error loop without do

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

2 Answers 2

1

Your missing and End If

but also you have Do ... Loop While

when it looks like it should be for your circumstances

Do While
....
Loop

or

Do Until
...
Loop
Sign up to request clarification or add additional context in comments.

Comments

0

Please add a end if to your code.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.