2

I want the program to output a message if no error is found.

   Sub casesVsQueue()
                 Dim loop_counter As Integer
                 Dim colD_counter As Integer
                 loop_counter = 1
                 colD_counter = 2
      Do Until IsEmpty(Sheets("Sheet1").Range("A" & loop_counter).Value)
              If IsError(Sheets("Sheet1").Range("C" & loop_counter).Value) Then      
                    Sheets("Sheet1").Range("D" & colD_counter).Value = Sheets("Sheet1").Range("A" & loop_counter).Value
                    colD_counter = colD_counter + 1

             End If
             loop_counter = loop_counter + 1
      Loop
End Sub
1
  • So is there a problem with your code currently? Commented Jun 6, 2016 at 20:48

2 Answers 2

1

At the very end after your loop, before you close your sub add this:

      Loop
    If colD_counter = 2 Then MsgBox "Everything is fine"
End Sub

Basically because colD_counter 'counts' errors, if it doesn't change during your loop, stays = 2, then you have msgbox saying no error come up.

You can leave the rest of your vb untouched. I just tried it out and it seems to work fine.

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

Comments

0

Is this what you are looking for?

Sub casesVsQueue()

Dim loop_counter As Integer
Dim colD_counter As Integer

Dim lngLastRow As Long

loop_counter = 1
colD_counter = 2

With ThisWorkbook.Worksheets("Sheet1")
    lngLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    For loop_counter = 1 To lngLastRow
        If VarType(.Cells(loop_counter, "C").Value) = vbError Or .Cells(loop_counter, "C").Value = vbNullString Then
            .Cells(colD_counter, "D").Value = .Cells(loop_counter, "A").Value
            colD_counter = colD_counter + 1
        End If
    Next loop_counter
End With

End Sub

Let me know if you have any problems or questions.

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.