Checking Cell Contents
Thanks, Tom. I cannot get this to work. Regardless of what I put into the
cells, it only returns the msgbox "All cells blank or contain other than text
constants". Any advice?
"Tom Ogilvy" wrote:
So I will assume the filled cells are constants (and not formulas
Sub CheckCells()
Dim rng as Range, rng1 as Range, cell as Range
Dim sStr as String
set rng = Range("A1,B9,F2,A10,M3")
On Error Resume Next
set rng1 = rng.specialcells(xlconstants,xltextvalues)
On Error goto 0
if rng1 is nothing then
msgbox "All cells blank or contain other than text constants"
else
sStr = rng1(1)
for each cell in rng1
if cell.Value < sStr then
msgbox "Not all the same
exit sub
End if
Next
msgbox rng1.count & " cells all contain " & sStr
End if
end Sub
--
Regards,
Tom Ogilvy
"Paige" wrote in message
...
Tom, the blank cells are empty.
"Tom Ogilvy" wrote:
Are the blank cells empty or are the values produced produced by
formulas?
=if(condition,"","horse")
type of formula.
--
Regards,
Tom Ogilvy
"Paige" wrote in message
...
Can someone advise how to do this; so far have been unsuccessful, but
I
think
it should be easy to do.
Example: There are 5 non-contiguous cells; for those cells (of these
5)
that have something in them (it would be text), I want to check to
ensure
that the content is all the same, ignoring those that are blank.
Note:
Sometimes all 5 cells could be blank, sometimes 4 could be blank and 1
have
an entry, or 3 blank and 2 with an entry, etc.
Thanks for any help you can provide....pc
|