View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default How to change parts of Cells().NumberFormat

Format(NumberFormat), "0.00") does not work.

Perhaps this will work...

C.NumberFormat = Replace(C.NumberFormat, ".0000", ".00")

where C is understood to be the cell (as a Range object) whose NumberFormat
you are changing. This code will not change any NumberFormats that do not
have ".0000" (without the quotes) in them; so it is safe to use on all cells
except those with ".0000" followed by additional characters as would be
found in NumberFormats with more than 4 zero-filled decimal places or,
perhaps, within text constants concatenated onto the NumberFormat.

--
Rick (MVP - Excel)


"FSPH" wrote in message
...
Hello there,

I assign Cells().NumberFormat to deal with various currencies.

Initially NumberFormat is "$#,##0.0000", "CHF#,##0.0000", etc.

I would like to keep the currency information, however, I want to have
only
2 digits (i.e., 0.00).

Format(NumberFormat), "0.00") does not work.

Any idea how I can cut off the last two digits without loosing the
currency
information?

Thank you for your help.