VBA

coquinn

New Member
Joined
Oct 23, 2005
Messages
24
I have a large data set of values some with the value of 0. I am attempting to calculate another worksheet by dividing 2 by these values using VBA...Unfortunately an error message keeps occuring as obviously you are not allowed to divide by 0...Is there any smart way round this? Unfortunately I am unable to adjust the data values so as to eliminate the zero values...
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Why not just use an If statement?

Code:
If c.Value<>0 Then
 ' do calculation
End If
 
Upvote 0
Hello Coquinn,

What do you want to happen in the other sheet when zero is encountered on the first one ? Do you just want to skip it ?

You could use an IF statement to check if the range is zero.

If rng = 0 then
'code to handle zero here
End If

Ciao,

Don.
 
Upvote 0

Forum statistics

Threads
1,203,224
Messages
6,054,237
Members
444,711
Latest member
Stupid Idiot

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