trap overflow of an division in vba

  • Thread starter Werner Rohrmoser
  • Start date
W

Werner Rohrmoser

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
 
S

Scoops

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top