ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   setting format in vb (https://www.excelbanter.com/excel-programming/323019-setting-format-vbulletin.html)

lynda

setting format in vb
 
Is it possible to set the format of a cell in vb?

I have a sheet with a calendar control and if the user
presses the calendar whilst on a cell with format of
number 2 decimal places the format changes to date making
any input to the cell invalid until the format is changed
back.

Thanks

Lynda

Bob Phillips[_6_]

setting format in vb
 
Lynda,

All cells can be changed by the Numberformat property, such as

ActiveCell.NumberFormt = "dd mmm yyyy"

or you can test it

If ActiveCell.Numberformat = "0.00" Then
...

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Lynda" wrote in message
...
Is it possible to set the format of a cell in vb?

I have a sheet with a calendar control and if the user
presses the calendar whilst on a cell with format of
number 2 decimal places the format changes to date making
any input to the cell invalid until the format is changed
back.

Thanks

Lynda




Tom Ogilvy

setting format in vb
 
Activecell.Numberformat = "#,###.00"

--
regards,
Tom Ogilvy

"Lynda" wrote in message
...
Is it possible to set the format of a cell in vb?

I have a sheet with a calendar control and if the user
presses the calendar whilst on a cell with format of
number 2 decimal places the format changes to date making
any input to the cell invalid until the format is changed
back.

Thanks

Lynda





All times are GMT +1. The time now is 01:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com