Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Instructions within VBA Functions


I defined a function in VBA that converts dates keyed in as YYYYMMDD t
be displayed as DD/MM/YYYY using "DateValue" command as well as th
Left, Mid and Right functions

However, excel will only display the dates in the serial numbers.

After the conversion into serial numbers (before 'end function'), i ha
this:


*ActiveCell.Select
Selection.NumberFormat = "dd/mm/yyyy"*


But somehow, it doesn't select that cell to convert into dd/mm/yyy
format.
I have to manually right click the cell and format it as date.

Is there anyway to do this in VBA

--
silves
-----------------------------------------------------------------------
silvest's Profile: http://www.excelforum.com/member.php...fo&userid=1466
View this thread: http://www.excelforum.com/showthread.php?threadid=26728

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Instructions within VBA Functions

Hi Silvest,

Not in a function; a function can not change anything in a worksheet. It can
only return a value to the position from which it was called (replace the
call with a value).
You can do what you require in a macro, or you can construct a function
which returns the date as a string. Of course the function call will need an
extra cell.

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

"silvest" wrote in message
...

I defined a function in VBA that converts dates keyed in as YYYYMMDD to
be displayed as DD/MM/YYYY using "DateValue" command as well as the
Left, Mid and Right functions

However, excel will only display the dates in the serial numbers.

After the conversion into serial numbers (before 'end function'), i had
this:


*ActiveCell.Select
Selection.NumberFormat = "dd/mm/yyyy"*


But somehow, it doesn't select that cell to convert into dd/mm/yyyy
format.
I have to manually right click the cell and format it as date.

Is there anyway to do this in VBA ?


--
silvest
------------------------------------------------------------------------
silvest's Profile:
http://www.excelforum.com/member.php...o&userid=14662
View this thread: http://www.excelforum.com/showthread...hreadid=267289



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Instructions within VBA Functions

The only reason the approach you show would not work (given that the cell to
be selected is in the activewindow) that I can think of is if your date
serial is being stored as a string rather than a number.

--
Regards,
Tom Ogilvy

"silvest" wrote in message
...

I defined a function in VBA that converts dates keyed in as YYYYMMDD to
be displayed as DD/MM/YYYY using "DateValue" command as well as the
Left, Mid and Right functions

However, excel will only display the dates in the serial numbers.

After the conversion into serial numbers (before 'end function'), i had
this:


*ActiveCell.Select
Selection.NumberFormat = "dd/mm/yyyy"*


But somehow, it doesn't select that cell to convert into dd/mm/yyyy
format.
I have to manually right click the cell and format it as date.

Is there anyway to do this in VBA ?


--
silvest
------------------------------------------------------------------------
silvest's Profile:

http://www.excelforum.com/member.php...o&userid=14662
View this thread: http://www.excelforum.com/showthread...hreadid=267289



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
In-Cell Instructions mckillmt Excel Discussion (Misc queries) 4 September 10th 18 10:56 AM
Template Instructions dd53 Excel Worksheet Functions 4 May 18th 09 10:21 PM
is there a way to do 4 instructions with one macro des-sa[_2_] Excel Discussion (Misc queries) 1 May 14th 08 09:37 PM
How to print detailed instructions for all functions in Excel? clark Excel Worksheet Functions 1 August 25th 05 10:47 AM
How to print detailed instructions for all functions in Excel? clark Excel Worksheet Functions 0 August 25th 05 04:26 AM


All times are GMT +1. The time now is 12:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"