ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   overflow error (https://www.excelbanter.com/excel-programming/426428-overflow-error.html)

Brad

overflow error
 

Using Excel 2007 - with compatibilty witn 2003.

Trying to find problems with my VBA code

I have a cell that is set up to accept dates (range named "cdate"). If an
individaul enter 04012009 in that cell, I get an "overfloww" error.

What options do I have to capture this event?

The VBA code breaks at the following line.
If Range("cdate").Value = "" Then


Brad

overflow error
 
One solution - are there better solutions

On Error GoTo ErrCorrect
..
..
..

ErrCorrect:
If Target.Address = Range("cdate").Address Then
MsgBox ("Please use slashes (/) when entering dates")
If Left(Range("prod1").Value, 3) = "LBD" Then
Range("cdate").Value = DateSerial(2007, 1, 1)
Else
Range("cdate").Value = DateSerial(1984, 12, 1)
End If
End If





"Brad" wrote:


Using Excel 2007 - with compatibilty witn 2003.

Trying to find problems with my VBA code

I have a cell that is set up to accept dates (range named "cdate"). If an
individaul enter 04012009 in that cell, I get an "overfloww" error.

What options do I have to capture this event?

The VBA code breaks at the following line.
If Range("cdate").Value = "" Then


FSt1

overflow error
 
hi
overflow problem usuallly stem from misdeclared dims so I think the real
problem is in your declarations. you may have the date set to integer.
integer will only hold up to 32700??or so. today's serial data is 39905
which would produce an overflow ie to big of a number for so small of
container.
in vb help type "data types" for more info on this.

regards
FSt1
"Brad" wrote:

One solution - are there better solutions

On Error GoTo ErrCorrect
.
.
.

ErrCorrect:
If Target.Address = Range("cdate").Address Then
MsgBox ("Please use slashes (/) when entering dates")
If Left(Range("prod1").Value, 3) = "LBD" Then
Range("cdate").Value = DateSerial(2007, 1, 1)
Else
Range("cdate").Value = DateSerial(1984, 12, 1)
End If
End If





"Brad" wrote:


Using Excel 2007 - with compatibilty witn 2003.

Trying to find problems with my VBA code

I have a cell that is set up to accept dates (range named "cdate"). If an
individaul enter 04012009 in that cell, I get an "overfloww" error.

What options do I have to capture this event?

The VBA code breaks at the following line.
If Range("cdate").Value = "" Then


Brad

overflow error
 
Since this is a cell in a worksheet I didn't "Dim" anything.




"FSt1" wrote:

hi
overflow problem usuallly stem from misdeclared dims so I think the real
problem is in your declarations. you may have the date set to integer.
integer will only hold up to 32700??or so. today's serial data is 39905
which would produce an overflow ie to big of a number for so small of
container.
in vb help type "data types" for more info on this.

regards
FSt1
"Brad" wrote:

One solution - are there better solutions

On Error GoTo ErrCorrect
.
.
.

ErrCorrect:
If Target.Address = Range("cdate").Address Then
MsgBox ("Please use slashes (/) when entering dates")
If Left(Range("prod1").Value, 3) = "LBD" Then
Range("cdate").Value = DateSerial(2007, 1, 1)
Else
Range("cdate").Value = DateSerial(1984, 12, 1)
End If
End If





"Brad" wrote:


Using Excel 2007 - with compatibilty witn 2003.

Trying to find problems with my VBA code

I have a cell that is set up to accept dates (range named "cdate"). If an
individaul enter 04012009 in that cell, I get an "overfloww" error.

What options do I have to capture this event?

The VBA code breaks at the following line.
If Range("cdate").Value = "" Then


FSt1

overflow error
 
hi
post all of your code.

Regards
FSt1

"Brad" wrote:

Since this is a cell in a worksheet I didn't "Dim" anything.




"FSt1" wrote:

hi
overflow problem usuallly stem from misdeclared dims so I think the real
problem is in your declarations. you may have the date set to integer.
integer will only hold up to 32700??or so. today's serial data is 39905
which would produce an overflow ie to big of a number for so small of
container.
in vb help type "data types" for more info on this.

regards
FSt1
"Brad" wrote:

One solution - are there better solutions

On Error GoTo ErrCorrect
.
.
.

ErrCorrect:
If Target.Address = Range("cdate").Address Then
MsgBox ("Please use slashes (/) when entering dates")
If Left(Range("prod1").Value, 3) = "LBD" Then
Range("cdate").Value = DateSerial(2007, 1, 1)
Else
Range("cdate").Value = DateSerial(1984, 12, 1)
End If
End If





"Brad" wrote:


Using Excel 2007 - with compatibilty witn 2003.

Trying to find problems with my VBA code

I have a cell that is set up to accept dates (range named "cdate"). If an
individaul enter 04012009 in that cell, I get an "overfloww" error.

What options do I have to capture this event?

The VBA code breaks at the following line.
If Range("cdate").Value = "" Then



All times are GMT +1. The time now is 04:28 PM.

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