Help with msgbox showing cell values

K

keri

Hi,

I have vba that compares the cells in A1:A10 with the cells in B1:B10.
If the value in A1 is not found in the range b1:b10 I get the error #N/
A in C1.

At the end of my code I would like to display a msgbox with a prompt

("These values were not found;")

and then a list of the values (the ones that caused the #N/A error in
column C

But I do not know how to do this.

Any help is very much appreciated.
 
V

Vasant Nanavati

Sub TestMe()
Dim s As String, c As Range
For Each c In Range("C1:C10")
If WorksheetFunction.IsNA(c) Then
If s = vbNullString Then
s = c.Offset(, -2)
Else
s = s & ", " & c.Offset(, -2)
End If
End If
Next
If s <> vbNullString Then
MsgBox "These values were not found." & vbNewLine & s
End If
End Sub
_____________________________________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top