Adjusting Formula to stop at 100% and not go over.

Walkerwood9

New Member
Joined
Jun 23, 2020
Messages
17
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a formula in a macro I am trying to adjust to not go over 100% like it currently does. It currently looks at a start and finish date and calculates a percentage of what should be done, but the only problem is that is goes over 100% when I want it to stop at 100% and not go over. Below is the code.



Range("P21").Select
Application.CutCopyMode = False
Selection.NumberFormat = "General"
ActiveCell.FormulaR1C1 = _
"=IF(RC[-2]<TODAY(),ROUND((DATEDIF(RC[-2],TODAY(),""D"")+1)/(DATEDIF(RC[-2],RC[-1],""D"")+1),2),0)"
Range("P21").Select
Selection.Style = "Percent"
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Try this as your formula
Rich (BB code):
"=IF(RC[-2]<TODAY(),MIN(ROUND((DATEDIF(RC[-2],TODAY(),""D"")+1)/(DATEDIF(RC[-2],RC[-1],""D"")+1),2),1),0)"
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,559
Members
449,089
Latest member
Motoracer88

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