View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default compare cell formats

I need the formula to, at least, identifiy which cells have information
associated with them.


There is no simple way to determine if a cell has been applied with one or
more non default format properties, whether inside or outside the UsedRange.

ALL cells have well over 30 individual format properties. You would need to
look each of these properties and compare with those of given cell or, to
check if not same as default, compare with the Normal style properties. Lot
of work and slow.

What's the overall objective, probably a simpler solution.

Regards,
Peter T

What is the purpose
"Gary''s Student" wrote in message
...
Hi Tom:

Thanks for the fast response.

However your function returns TRUE for two cells, one of which is
left-justified and the other right-justified.

I am working with a worksheet that appeared to be completely empty. It

was
over 800K in size! Although all the cells are empty,

ActiveSheet.UsedRange
covered over 2000 cells.

I discovered that the information has been encoded in the cell's formats
rather than the cell's contents. The cells have different fonts, font

sizes.
Some are bold, some are underlined. Some are right-justified, some
left-justified.

None of the cells have contents, background colors or borders; so none of
the formatting differences are visible to the naked eye.

I need the formula to, at least, identifiy which cells have information
associated with them.

Thanks again for your help.
--
Gary''s Student


"Tom Ogilvy" wrote:

Public Function FormatTest(rng1 as Range, rng2 as Range) as Boolean
FormatTest = False
if rng2.count 1 or rng1.count 1 then exit sub
If rng2.numberformat = rng1.numberformat then
FormatTest = True
end if
End Function

This is pretty literal. It will show false for

"#,##0" = "#,##0;-#,##0"

another approach might be

Public Function FormatTest(rng1 as Range, rng2 as Range) as Boolean
FormatTest = False
if rng2.count 1 or rng1.count 1 then exit sub
If rng2.text = Format(rng2.value2,rng1.numberformat) and _
rng1.Text = Format(rng1.value2,rng2.numbeformat) then
FormatTest = True
end if
End Function

--
Regards,
Tom Ogilvy


"Gary''s Student" wrote:

I need a simple boolean function that will return TRUE if the formats

of two
cells are identical, otherwise FALSE. (the contents of the cells are

always
empty)


For example =formatest(A1,B2)
--
Gary's Student