Error 6: Overflow

CMDMA03

New Member
Joined
Sep 23, 2011
Messages
12
I keep getting error 6: overflow when my macro encounters a division error. Is there any way to account for a division error (i.e., division by 0) within the calculations below? Like maybe embedding an if statement?


Code:
dblGRAdminValue = -.Worksheets("MH-III (landscape)").Range("K42") / _
        .Worksheets("MH-III (landscape)").Range("AW42")                 'captures the GR Admin % value
        dblMHBGAdminValue = -.Worksheets("MH-III (landscape)").Range("K47") / _
        .Worksheets("MH-III (landscape)").Range("AW47")                 'captures the MHBG Admin % value
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Code:
    With .Worksheets("MH-III (landscape)")
        If .Range("AW42").Value <> 0 Then
            dblGRAdminValue = -.Range("K42").Value / .Range("AW42").Value
        Else
            ' what?
        End If
 
        If .Range("AW47").Value <> 0 Then
            dblMHBGAdminValue = -.Range("K47") / .Range("AW47").Value
        Else
            ' what?
        End If
    End With
 
Upvote 0
Thanks; worked like a charm.

Code:
With .Worksheets("MH-III (landscape)")
            If .Range("K42").Value <> 0 Then
                dblGRAdminValue = -.Range("K42") / .Range("AW42")
            
            Else
                
                 dblGRAdminValue = 0.0000001
            
            End If
        
            If .Range("K47").Value <> 0 Then
                dblMHBGAdminValue = -.Range("K47") / .Range("AW47")
            
            Else
                
                dblMHBGAdminValue = 0.0000001
            
            End If
            
End With
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top