0

I want to have a MsgBox pop up with a list of names that have missing info (either phone number or address). So far I have:

Dim missing As String
Do While Cells(i, 1).Value <> ""
    If StrComp(Cells(i, 1), "Need address") = 0 Then missing = Cells(i - 2, 1)
Loop
MsgBox missing

The spreadsheet is formatted to have all client info in Column A in the order of:

Name

Phone Number

Address

So far, I just a 1004 Runtime Error

1
  • 1
    Whats is the value of i? Commented Jun 22, 2015 at 11:50

2 Answers 2

1

You must initialize and increment i

Sub dural()
    Dim missing As String, i As Long
    i = 1

    Do While Cells(i, 1).Value <> ""
        If StrComp(Cells(i, 1), "Need address") = 0 Then missing = Cells(i - 2, 1)
        i = i + 1
    Loop
    MsgBox missing
End Sub

without initializing i, it starts at 0 and that is the source of the error.

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

Comments

0

Where is 'i' starting? because (i - 2) can be -2 which is not a row # in excel.

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.