Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a text box where the user enters a date and it is assigned to variable
txtDate. How to I convert that to the serial number of the date? Thanks for the help |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
IIRC, you can use
DATEVAL(String) to get the serial date. -- HTH, Barb Reinhardt "VinceW" wrote: I have a text box where the user enters a date and it is assigned to variable txtDate. How to I convert that to the serial number of the date? Thanks for the help |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Barb,
Thanks for the quick reply, however I get the error "Sub or Function not defined" when trying that. Any suggestions? "Barb Reinhardt" wrote: IIRC, you can use DATEVAL(String) to get the serial date. -- HTH, Barb Reinhardt "VinceW" wrote: I have a text box where the user enters a date and it is assigned to variable txtDate. How to I convert that to the serial number of the date? Thanks for the help |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
My apologies. It's DateValue.
-- HTH, Barb Reinhardt "VinceW" wrote: Barb, Thanks for the quick reply, however I get the error "Sub or Function not defined" when trying that. Any suggestions? "Barb Reinhardt" wrote: IIRC, you can use DATEVAL(String) to get the serial date. -- HTH, Barb Reinhardt "VinceW" wrote: I have a text box where the user enters a date and it is assigned to variable txtDate. How to I convert that to the serial number of the date? Thanks for the help |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I started with DateValue before searching for an answer here, thinking that
would do it. I have a breakpoint so I can see the value of DateValue(txtDate) and it shows me the date of 11/16/2008 rather than the serial number. I am really confused on this one. Thanks for your assistance and any further suggestions. "Barb Reinhardt" wrote: My apologies. It's DateValue. -- HTH, Barb Reinhardt "VinceW" wrote: Barb, Thanks for the quick reply, however I get the error "Sub or Function not defined" when trying that. Any suggestions? "Barb Reinhardt" wrote: IIRC, you can use DATEVAL(String) to get the serial date. -- HTH, Barb Reinhardt "VinceW" wrote: I have a text box where the user enters a date and it is assigned to variable txtDate. How to I convert that to the serial number of the date? Thanks for the help |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() -- Don Guillett Microsoft MVP Excel SalesAid Software "VinceW" wrote in message ... I have a text box where the user enters a date and it is assigned to variable txtDate. How to I convert that to the serial number of the date? Thanks for the help |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
text box ?? Do you mean inputbox?
-- Don Guillett Microsoft MVP Excel SalesAid Software "VinceW" wrote in message ... I have a text box where the user enters a date and it is assigned to variable txtDate. How to I convert that to the serial number of the date? Thanks for the help |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Barb.....Oh my what a simple problem this really was. The DateValue is the
correct function to use. Although the date is shown as 11/16/2009 and the code puts that in the cell requested, I simply changed the format of the cell to be numeric ans the serial number 40133 is there just as it should be!!!! Sometimes it is the forest and the trees syndrome!!.... Thanks for your help and suggestions. "Barb Reinhardt" wrote: My apologies. It's DateValue. -- HTH, Barb Reinhardt "VinceW" wrote: Barb, Thanks for the quick reply, however I get the error "Sub or Function not defined" when trying that. Any suggestions? "Barb Reinhardt" wrote: IIRC, you can use DATEVAL(String) to get the serial date. -- HTH, Barb Reinhardt "VinceW" wrote: I have a text box where the user enters a date and it is assigned to variable txtDate. How to I convert that to the serial number of the date? Thanks for the help |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Mon, 16 Nov 2009 06:01:07 -0800, VinceW
wrote: I have a text box where the user enters a date and it is assigned to variable txtDate. How to I convert that to the serial number of the date? Thanks for the help One question I have is "what do you mean by 'the serial number of the date'"? MS stores dates using serial numbers where 1 = 1 Jan 1900 (depending on which date system you are using). If txtDate is a string, then to show the "serial number" you could use something like: clng(datevalue(txtdate)) If you mean something else by "serial number of the date", please be more specific. --ron |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Don,
I am using a text box on a user form for the user to enter their date. Could not figure out how to convert the date string to a serial number. However the DateValue function does work as long as the cell in the spreadsheet is formatted as numeric. Thanks for the reply "Don Guillett" wrote: -- Don Guillett Microsoft MVP Excel SalesAid Software "VinceW" wrote in message ... I have a text box where the user enters a date and it is assigned to variable txtDate. How to I convert that to the serial number of the date? Thanks for the help . |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you don't want to always change the date to a numeric value, you can use
this to get the serial number... SerialNumber = CDbl(CDate(Range("A1").Value)) Just change the cell reference as needed. Of course, the Range("A1").Value part could be replaced by any String value if needed (say, from a TextBox as an example). -- Rick (MVP - Excel) "VinceW" wrote in message ... Barb.....Oh my what a simple problem this really was. The DateValue is the correct function to use. Although the date is shown as 11/16/2009 and the code puts that in the cell requested, I simply changed the format of the cell to be numeric ans the serial number 40133 is there just as it should be!!!! Sometimes it is the forest and the trees syndrome!!.... Thanks for your help and suggestions. "Barb Reinhardt" wrote: My apologies. It's DateValue. -- HTH, Barb Reinhardt "VinceW" wrote: Barb, Thanks for the quick reply, however I get the error "Sub or Function not defined" when trying that. Any suggestions? "Barb Reinhardt" wrote: IIRC, you can use DATEVAL(String) to get the serial date. -- HTH, Barb Reinhardt "VinceW" wrote: I have a text box where the user enters a date and it is assigned to variable txtDate. How to I convert that to the serial number of the date? Thanks for the help |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ron,
Thanks again for another very simple solution to what I was looking for. That also works fine. Ever have one of those days where the brain turns a problem into something more difficult than it really is! Thanks for your reply. "Ron Rosenfeld" wrote: On Mon, 16 Nov 2009 06:01:07 -0800, VinceW wrote: I have a text box where the user enters a date and it is assigned to variable txtDate. How to I convert that to the serial number of the date? Thanks for the help One question I have is "what do you mean by 'the serial number of the date'"? MS stores dates using serial numbers where 1 = 1 Jan 1900 (depending on which date system you are using). If txtDate is a string, then to show the "serial number" you could use something like: clng(datevalue(txtdate)) If you mean something else by "serial number of the date", please be more specific. --ron . |
#13
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Mon, 16 Nov 2009 08:37:01 -0800, VinceW
wrote: Ron, Thanks again for another very simple solution to what I was looking for. That also works fine. Ever have one of those days where the brain turns a problem into something more difficult than it really is! Thanks for your reply. You're welcome. Glad to help. And yes, I do have those days; often followed by hours of kicking myself over the time I've lost! --ron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy/Paste cell down to next value- Easy question, can't figure it | Excel Discussion (Misc queries) | |||
Easy Problem that I can't figure out | Excel Discussion (Misc queries) | |||
sounds easy but I can't figure it out..... | Excel Programming | |||
UDFs needed I think they're pretty easy but I can't figure them ou | Excel Programming | |||
Maybe an easy If / Then statement? But I can't figure it out. Help! | Excel Programming |