Hello,
I'm having a small issue with this piece of code:
![]()
Option Explicit Sub DataValidation() Dim c As Range Dim Msg1 As Integer Dim Err As String For Each c In Range("A2:B21").Cells Err = Application.WorksheetFunction.VLookup("Error 1", Worksheets("Sheet1").Range("O28:P33"), 2, False) If c.Value <> "Good" Then Msg1 = MsgBox(c & " in Row " & c.Row & Err, vbYesNo) If Msg1 = vbNo Then Exit Sub Next MsgBox ("Good") End Sub
The goal is to get the VLOOKUP to use c.Value, just like I do in the next line, to look up the corresponding error explanation located just below the list of Errors. It keeps giving me the red circle with white X accompanied by "400".
If I get rid of c.Value and put "Error 1", it works fine. But obviously, it's in a loop and this is because the error can change so I want the corresponding message.
Attached is the sample workbook:
VLookupError400.xlsm
Any Ideas? Thanks!
Bookmarks