ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can I change the caller cell's format into "mm/dd/yyyy"? (https://www.excelbanter.com/excel-programming/405796-how-can-i-change-caller-cells-format-into-mm-dd-yyyy.html)

[email protected]

How can I change the caller cell's format into "mm/dd/yyyy"?
 
I have a user defined function which returns a date. I want to set the
caller cell's format to "Date" before placing my result. How can i do
that?
I tried with this code but i am getting a number...If i change the
cell format into date manully, it works fine.

Function ReturnDate() as date
ReturnDate="2/11/2008"
range(application.caller.address).numberformat="mm/dd/yyyy"
End Function

Inside sheet...
=ReturnDate()

where did i go wrong?


Gary''s Student

How can I change the caller cell's format into "mm/dd/yyyy"?
 
A UDF cannot change a cell's format. Just set the format in the worksheet in
the usual way.
--
Gary''s Student - gsnu2007d


" wrote:

I have a user defined function which returns a date. I want to set the
caller cell's format to "Date" before placing my result. How can i do
that?
I tried with this code but i am getting a number...If i change the
cell format into date manully, it works fine.

Function ReturnDate() as date
ReturnDate="2/11/2008"
range(application.caller.address).numberformat="mm/dd/yyyy"
End Function

Inside sheet...
=ReturnDate()

where did i go wrong?




All times are GMT +1. The time now is 10:53 PM.

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