If *Total* make row white

R

ryguy7272

I grabbed this from another macro that I have:
Dim lastrow As Long, j As Long
lastrow = Cells(Rows.Count, 5).End(xlUp).Row
For j = lastrow To 1 Step -1
If (Cells(j, 5).Value) Like "*Total*" Then
Rows(j).Interior.ColorIndex = xlNone
End If
Next

Other macro worked great, but the way. I tried to white out each row, and
now it doesn't work. Been looking at all kinds of code for about 10 hours
now. My eyes need a rest. Can someone see the problem?

Thanks!
Ryan--
 
R

ryguy7272

Well, I just found the culprit; I have this in two cells (one of each):
#VALUE!
#VALUE! Total

How can I compensate for this?

Thanks,
Ryan---
 
R

ryguy7272

I got it working with this:

Dim j As Long
For j = Cells(Rows.Count, "E").End(xlUp).Row To 1 Step -1
If InStr(1, Cells(j, 5).Text, "Total", vbTextCompare) <> 0 Then
Rows(j).Interior.ColorIndex = xlNone
Rows(j + 1).Interior.ColorIndex = xlNone
End If
Next

The above code is from Jacob Skaria! Genius!! I swear I tried that earlier
in the evening and it didn't work. It was a long day...

Other solutions work, but it seems like Jacob's solution is the only one
that worked with those dang #VALUE! things in there.


Thanks all!
Ryan---
 

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