Help with msgbox showing cell values

  • Thread starter Thread starter keri
  • Start date Start date
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.
 
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
_____________________________________________________________________
 
Back
Top