VBA format cells

M

MJ

Hi...

I was wondering if there is a way for visual basic to pick
up an Excel cell's format properties like "Category"
(general, currency, percentage, etc.)

Also if the Category is set to "Number", can VB pick up
the "Decimal places" property?

Any help? Thanks!

MJ
 
P

Pete McCosh

MJ,

Activecell.numberformat will give you this in the same way
that you would define it, or in the same way it shows in
the "custom" section of the Format>>Number dialogue box.

For example, format a cell to normal number format to two
decimal places. In the immediate window, type:
?Activecell.Numberformat

it should return "0.00". Change the format to four decimal
places, check again and it will have changed to "0.0000".

That should get you started.

Cheers, Pete.
 
M

MJ

That satisfies my needs... thanks guys!

MJ

-----Original Message-----
MJ,

Activecell.numberformat will give you this in the same way
that you would define it, or in the same way it shows in
the "custom" section of the Format>>Number dialogue box.

For example, format a cell to normal number format to two
decimal places. In the immediate window, type:
?Activecell.Numberformat

it should return "0.00". Change the format to four decimal
places, check again and it will have changed to "0.0000".

That should get you started.

Cheers, Pete.

.
 
Top