Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default trap overflow of an division in vba

Hello,

how can I trap an overflow error for a division made in vba code?

Example:
..
other coding
..
If IsError(.Cells(1, 1).Offset(0, -2).Value / .Cells(BaseRangeRow,
1).Offset(0, -2).Value) Then
.Cells(1, 1).Value = CVErr(xlErrNA)
Else
.Cells(1, 1).Value = .Cells(1, 1).Offset(0,
-2).Value / .Cells(BaseRangeRow, 1).Offset(0, -2).Value
End If
..
other coding
..

When the denomonator is 0, then the procedure stops with an eeror
message "Overflow"

Any idea to manage this situation?

Excel XP SP3
WIN XP SP1

Regards
Werner
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default trap overflow of an division in vba

Use On Error
--
Gary''s Student - gsnu2007g


"Werner Rohrmoser" wrote:

Hello,

how can I trap an overflow error for a division made in vba code?

Example:
..
other coding
..
If IsError(.Cells(1, 1).Offset(0, -2).Value / .Cells(BaseRangeRow,
1).Offset(0, -2).Value) Then
.Cells(1, 1).Value = CVErr(xlErrNA)
Else
.Cells(1, 1).Value = .Cells(1, 1).Offset(0,
-2).Value / .Cells(BaseRangeRow, 1).Offset(0, -2).Value
End If
..
other coding
..

When the denomonator is 0, then the procedure stops with an eeror
message "Overflow"

Any idea to manage this situation?

Excel XP SP3
WIN XP SP1

Regards
Werner

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default trap overflow of an division in vba

On 4 Apr, 16:14, Werner Rohrmoser wrote:
Hello,

how can I trap an overflow error for a division made in vba code?

Example:
.
other coding
.
If IsError(.Cells(1, 1).Offset(0, -2).Value / .Cells(BaseRangeRow,
1).Offset(0, -2).Value) Then
* *.Cells(1, 1).Value = CVErr(xlErrNA)
Else
* *.Cells(1, 1).Value = .Cells(1, 1).Offset(0,
-2).Value / .Cells(BaseRangeRow, 1).Offset(0, -2).Value
End If
.
other coding
.

When the denomonator is 0, then the procedure stops with an eeror
message "Overflow"

Any idea to manage this situation?

Excel XP SP3
WIN XP SP1

Regards
Werner


Hi Werner

If "denominator" = 0 Then
'Do nothing
Else
Run code
End if

Regards

Steve
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default trap overflow of an division in vba

Thanks Scoops,

simple and good.

Werner
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default trap overflow of an division in vba

Thanks Gary,

yes, works as well.

Werner
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
Overflow jmdaniel Excel Programming 4 September 5th 06 07:09 PM
Overflow Erik Beck Jensen Excel Programming 2 December 13th 05 10:11 AM
can't trap overflow error! Kate Excel Programming 6 May 13th 05 03:52 PM
VBA overflow Tom Ogilvy Excel Programming 3 September 2nd 03 09:04 PM
VBA overflow Don Guillett[_4_] Excel Programming 2 September 2nd 03 04:19 PM


All times are GMT +1. The time now is 08:51 PM.

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"