return multiple cell references

G

Guest

My sheet could have anywhere from 1 to 200 rows.

A B C
1 Jones 9 8
2 Smith 3
3 Jones 6 6
4 Clark 4 3
5 Young 1 1

There's alot of other data in numerous sheets which gets summarized on one
sheet. From this sheet I need to find the row numbers is C>0 and B<>C. The
problem is I need a one line answer for the summary sheet (ex - The following
rows have errors: 1, 4). Is there anyway to do this? Due to the way my data
is compiled, I am unable to use Data Validation.

Thanks!
 
D

Dave Peterson

How about an alternative.

Add headers in row 1.
Add an new column with formulas like:
=if(and(c2>2,b2<>c2),"Error","")

And then drag down the column.

Select that new column and do Data|Filter|Autofilter to show just the Error's.
 
G

Guest

For a single line summary, run this macro:

Sub laszlo()
Dim n As Long, m As Integer
Dim bv As Integer, cv As Integer
n = Cells(Rows.Count, "A").End(xlUp).Row
messagee = "The following rows have errors: "
For i = 1 To n
bv = Cells(i, "B").Value
cv = Cells(i, "C").Value
If cv > 0 And bv <> cv Then
messagee = messagee & i & ", "
End If
Next
Range("D1").Value = Left(messagee, Len(messagee) - 2)
End Sub
 
G

Guest

Thank you so much! I added this to my existing (& very elementary) macro and
it worked out great. One thing though... what can I do if none of the rows
have errors? If there a way to have no message?
 
G

Guest

Thanks for responding. I had tried that formula too although I had forgotten
about the autofilter function. This is a monthly spreadsheet so I wanted
something that would calculate automatically each time the sheet was updated.
I already have a macro in it to create the summary sheet, so I was able to
incorporate Gary"s Student's suggestion. Now I just need to figure out how
to skip the error message if there are no errors.

Thanks again!
 

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