Apply round formula to range of cells + autofill

fruela

New Member
Joined
Oct 23, 2020
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

On the table below, the formula for column B is
Excel Formula:
=ROUND(T2/5;0)*5

I want to automate in vba. I have used the below in other cases, can I adapt with the formula above instead of "=O2/S2" ?

VBA Code:
Sub firstMonth()
    Range("T2").Formula = "=O2/S2"
    Range("T2").AutoFill Range("T2:T" & Range("A" & Rows.Count).End(xlUp).Row)
End Sub

Thank you! Cheers


First Month ValueFirst Month Value (round)
283,3333333​
285,00​
250​
250,00​
283,3333333​
285,00​
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
If you want to round to the nearest multiple of 5
VBA Code:
Range("T2:T" & Range("A" & Rows.Count).End(xlUp).Row).Formula="=MROUND(O2/S2,5)"
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,917
Members
449,093
Latest member
dbomb1414

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