Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Date and sequential serial numbers

Hi

I am using a date that i have in an excel sheet in VBA and would like the value to be the sequential serial number and not the date. I am using this value for calculations, and it does not work if the "value" is 12/02/2003 instead 38029

How do I get the value in sequential serial number instead of the date.

Rgds

Peter B
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Date and sequential serial numbers

Hi Peter
for calculation the format of this date value should have no affect
(that ist your value '12/02/2003' is a ddate and not a textvalue).
Internally Excel treats both representations as the same (you may have
to format the resulting cell).
Maybe you can post what kind o f calculation you're trying to achieve

Frank

Peter B wrote:
Hi,

I am using a date that i have in an excel sheet in VBA and would like
the value to be the sequential serial number and not the date. I am
using this value for calculations, and it does not work if the
"value" is 12/02/2003 instead 38029.

How do I get the value in sequential serial number instead of the
date.

Rgds,

Peter B



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Date and sequential serial numbers


I have dimmed startdato as Integer and would simply add 1. The line that doesnt work is this one:
Startdato = Range("Date").Value + 1

When I am trying to do this, I get the message:
"Run-time error '6':

Overflow"

Any suggestions?

Peter

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Date and sequential serial numbers

Peter,

Is the Date cell formatted as date? What is in there? How have you declared
Startdato?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Peter B" wrote in message
...

I have dimmed startdato as Integer and would simply add 1. The line that

doesnt work is this one:
Startdato = Range("Date").Value + 1

When I am trying to do this, I get the message:
"Run-time error '6':

Overflow"

Any suggestions?

Peter



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Date and sequential serial numbers

Hi,

Dim startdato as date instead - and it will work like a charm.
I have also included how you can convert the date to serial if you should
need it...

Sub TestTheDate()

Dim startdato As Date
Dim dblStartDatoSerial As Double

startdato = Range("Date").Value + 1

MsgBox startdato

' Convert startdato to serial if you should need that
' you can also use the DATE worksheet function for this.
dblStartDatoSerial = CDbl(startdato)

MsgBox dblStartDatoSerial

End Sub

Hope this helps

/Ulrik

"Peter B" wrote in message
...

I have dimmed startdato as Integer and would simply add 1. The line that

doesnt work is this one:
Startdato = Range("Date").Value + 1

When I am trying to do this, I get the message:
"Run-time error '6':

Overflow"

Any suggestions?

Peter





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Date and sequential serial numbers

The date cell is formatted as Date yes (in Excel). In that cells is todays date, by using the formula =Today(). I have declared Startdato as an Integer (DIM startdato as Integer)

Rgds

Peter B
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Date and sequential serial numbers

Hi Peter
two ideas:
- define startdato as date
- What kind of value is in you range 'Date'

Otherwise this works fine for me

Frank

you may have to
Peter B wrote:
I have dimmed startdato as Integer and would simply add 1. The line
that doesnt work is this one: Startdato = Range("Date").Value + 1

When I am trying to do this, I get the message:
"Run-time error '6':

Overflow"

Any suggestions?

Peter



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Date and sequential serial numbers

Peter,

I thought so. The problem is that today's date is value 38030, whereas an
integer will only hold 32000+, so it overflows. Declare StartDato as a Long,
and all will be okay. If you could work in time, then declare it as Double.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Peter B" wrote in message
...
The date cell is formatted as Date yes (in Excel). In that cells is todays

date, by using the formula =Today(). I have declared Startdato as an Integer
(DIM startdato as Integer).

Rgds,

Peter B



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Date and sequential serial numbers

Bob already advised you as to the problem with having your value as an
integer. Just to add, you can use the Value2 property to get the dateserial
as a number rather than a date (although it should be converted just through
the assignment to a long or double).

--
Regards,
Tom Ogilvy

"Peter B" wrote in message
...
The date cell is formatted as Date yes (in Excel). In that cells is todays

date, by using the formula =Today(). I have declared Startdato as an Integer
(DIM startdato as Integer).

Rgds,

Peter B



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
generate serial numbers and date it entered irealtymods Excel Discussion (Misc queries) 3 August 5th 09 08:16 AM
Changing text dates to date serial numbers George[_5_] Excel Worksheet Functions 6 January 2nd 08 10:44 PM
Date to TEXT. NOT to sequential serial number Gene Excel Discussion (Misc queries) 2 May 26th 06 09:33 PM
Renaming Sequential Rows to create serial numbers forceten32 Excel Worksheet Functions 4 November 13th 05 11:17 PM
Changing date serial numbers rdunne Excel Discussion (Misc queries) 1 April 14th 05 12:57 PM


All times are GMT +1. The time now is 06:27 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"