allowing a maximum number in a cell which contains a formula and/or reference to other cells / workbooks

sjoerd.bosch

New Member
Joined
Feb 9, 2012
Messages
49
Hi. I am looking for a VBA code what prevents a result of a formula to exceed 98% (the number 98 only will do)
The cells(s) which I want to restrict contain formulas, which will not allow me to use the data function in excel.
the VBA code must return with a msg box telling the user to enter a valid number

Like in the below image - I enter in the Ullage UTI Cell(s) (blue) a certain measurement in mm - it then calculates a correction and gives me a new Final Ullage and in the next cell a percentage. If the final ullage exceeds a maximum allowable number it would result in more than 98% volume loaded in the next cell.
If that is the case, I want the program to stop calculating and show an error message saying something like - "Error! You are overloading the tank. Please enter a valid Ullage"
The actual message is not very important.
I just cannot find any solution because the cell I want to restrict contains a formula which refers to another cell.

Your kind assistance is very much appreciated.



Annotation 2021-03-13 190942.png
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,214,826
Messages
6,121,797
Members
449,048
Latest member
greyangel23

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