VBA - #DIV/0! Error After Copy and Paste

foolishpiano

New Member
Joined
Aug 19, 2016
Messages
25
Hello everyone! I'm trying to copy the value from a formula and paste the result as a value only, but when the code is run I receive a #DIV/0! error. The code I have is:

Code:
Range("S4").Activate
      Selection.Formula = "=average(O15:O500)"
Range("S5").Select
      ActiveCell.FormulaR1C1 = "=DATEDIF(R[-1]C,TODAY(),""d"")"
Range("S5").Select
      Selection.Copy
           Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False

Any ideas on how to fix the error, or why it's occurring?

Thank you all!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
The only division related function in your code is Average.
The entire range O15:O500 is zero or text. That would produce a DIV/0 error
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,369
Members
449,080
Latest member
Armadillos

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