Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Passing Excel formats in VBA date variables

I have a start date in my spreadsheet model that is formatted as follow
(m/d/yyyy h:mm). I have named the cell "xlStartDate" I have a VB
variable that is called StartDate. I pass the excel variable to th
vba variable

Dim StartDate As Date
StartDate = Range("xlStartDate")


When I put my cursor over teh StartDate varible it says 01/01/2004.
Why does it not have the formatting of m/d/yyyy h:mm

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Passing Excel formats in VBA date variables

ExcelMonkey,

StartDate is just a date variable. It contains a date and that's all - no
formatting.
The format in the tooltip you're seeing is a format defined by your regional
settings.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"ExcelMonkey " wrote in message
...
I have a start date in my spreadsheet model that is formatted as follows
(m/d/yyyy h:mm). I have named the cell "xlStartDate" I have a VBA
variable that is called StartDate. I pass the excel variable to the
vba variable

Dim StartDate As Date
StartDate = Range("xlStartDate")


When I put my cursor over teh StartDate varible it says 01/01/2004.
Why does it not have the formatting of m/d/yyyy h:mm?


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Passing Excel formats in VBA date variables

If I want to format it do I use a format function or a format method o
the vba variable

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Passing Excel formats in VBA date variables


Yes, you would use the format function when you wanted to show the date as a
string.
eg.

Sub test()
Dim dtmTemp As Date

dtmTemp = Now()

MsgBox dtmTemp 'automatically formats as defined by regional settings

MsgBox Format(dtmTemp, "dd-Mmm-yyyy HH:mm")
End Sub




--
Rob van Gelder - http://www.vangelder.co.nz/excel


"ExcelMonkey " wrote in message
...
If I want to format it do I use a format function or a format method on
the vba variable?


---
Message posted from http://www.ExcelForum.com/



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
VBA - passing Variables to subroutines Madduck Excel Discussion (Misc queries) 12 September 19th 08 03:20 AM
Passing Variables Jeff Excel Discussion (Misc queries) 1 November 4th 05 06:46 PM
VBA passing variables through a function Jeff Excel Discussion (Misc queries) 2 November 3rd 05 11:23 PM
Passing Variables Royce[_2_] Excel Programming 1 November 20th 03 02:16 PM
passing variables from excel to word Mike NG Excel Programming 8 July 22nd 03 12:08 PM


All times are GMT +1. The time now is 05:15 AM.

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

About Us

"It's about Microsoft Excel"