In Excel, I am trying to write a formula that checks whether any cell in certain range of cells contains invalid data, according to each cell’s data validation rules. I want to use this information to display a message in a cell near the top of the sheet, so the user doesn’t have to scroll through the whole sheet to see if it contains any invalid data.
All the cells in the range I want to check use the same rules for their data validation, but these rules are fairly complex and are dependent on the values of other cells in each row. I already know that you can check whether any cell in a given column equals a certain value using the VLOOKUP Function, (E.g. =IF(ISNA(VLOOKUP("Lookup Value", A1:A20, 1, FALSE)), "Not Found", "Found")), but there doesn’t seem to be any way to use that same method to check for cells with invalid data.
Is there a way to do this in Excel without using VBA? If not, can you recommend an alternative solution?
So any row is invalid if it contains Fail or N/A in column D and column E in the same row is blank?
Try using COUNTIFS to see if there are any invalid rows, e.g. this formula at the top
=IF(SUM(COUNTIFS(D:D,{"Fail","N/A"},E:E,"")),"Invalid Data","All OK")or this version will give you the number of instances
=IF(SUM(COUNTIFS(D:D,{"Fail","N/A"},E:E,"")),SUM(COUNTIFS(D:D,{"Fail","N/A"},E:E,""))&" Row(s) of Invalid Data","All OK")COUNTIFS is only valid in Excel 2007 or later, in earlier versions you can count invalid rows with SUMPRODUCT, i.e.
=SUMPRODUCT((D1:D1000={"Fail","N/A"})*(E1:E1000=""))