Data Validation custom formula length restriction?

lovemy65stang

New Member
Joined
Jan 28, 2008
Messages
4
I am quite familiar with data validation, and writing custom data validation formulas. I am having a frustrating problem though and can't seem to figure out a way around it. I'm trying to enter the following custom data validation formula into cell F17, but it appears that the formula is too long to be entered:
Code:
=IF(ISBLANK(D17),F17="",AND(ISNUMBER(F17),OR(AND(ISNUMBER(B20),ISNUMBER(B21),F17+(G17/12)+(I17/12*0.5)<=B20,F17+(G17/12)-(I17/12*0.5)>=B21),AND(ISNUMBER(B39),ISNUMBER(B40),F17+(G17/12)+(I17/12*0.5)<=B39,F17+(G17/12)-(I17/12*0.5)>=B40),AND(ISNUMBER(B58),ISNUMBER(B59),F17+(G17/12)+(I17/12*0.5)<=B58,F17+(G17/12)-(I17/12*0.5)>=B59),AND(ISNUMBER(B77),ISNUMBER(B78),F17+(G17/12)+(I17/12*0.5)<=B77,F17+(G17/12)-(I17/12*0.5)>=B78),AND(ISNUMBER(B96),ISNUMBER(B97),F17+(G17/12)+(I17/12*0.5)<=B96,F17+(G17/12)-(I17/12*0.5)>=B97))))
I'm using Excel 2000 at my workplace. Do newer versions of Excel allow for longer formulas? Is there a way to make the formula shorter, but still function the same? I'm stumped :confused: Any help would be greatly appreciated!
-Brian
 
The problem isn't the length of the formula, it's that the formula doesn't make sense... it doesn't follow the syntax of an IF-statement...
=IF(condition, true value, false value)
You have the following, which has as it's true value -- F17="" which results in TRUE or FALSE, and as it's False value, the rest of the formuls, which, since it's enclosed in an AND-statement, is also just True or False, which is MAYBE what you want, but unlikely. You can put this formula in a cell, say K17, and use =K17 as the conditional format test. It'd also make it easier to debug!

=IF(ISBLANK(D17),F17="",AND(ISNUMBER(F17),OR(AND(ISNUMBER(B20),ISNUMBER(B21),F17+(G17/12)+(I17/12*0.5)<=B20,F17+(G17/12)-(I17/12*0.5)>=B21),AND(ISNUMBER(B39),ISNUMBER(B40),F17+(G17/12)+(I17/12*0.5)<=B39,F17+(G17/12)-(I17/12*0.5)>=B40),AND(ISNUMBER(B58),ISNUMBER(B59),F17+(G17/12)+(I17/12*0.5)<=B58,F17+(G17/12)-(I17/12*0.5)>=B59),AND(ISNUMBER(B77),ISNUMBER(B78),F17+(G17/12)+(I17/12*0.5)<=B77,F17+(G17/12)-(I17/12*0.5)>=B78),AND(ISNUMBER(B96),ISNUMBER(B97),F17+(G17/12)+(I17/12*0.5)<=B96,F17+(G17/12)-(I17/12*0.5)>=B97))))
 
Upvote 0
The problem is not with the formula itself. I've poured over it multiple times and everything is as I need it to be. The if statement is more complex than the following, but this might give a better idea of what it's checking for:

Code:
if D17 is blank then
{
    F17 must be blank
}
else
{
    F17 must be a number
    AND
    {
        B20 <= F17 <= B21
        OR
        B39 <= F17 <= B40
        OR
        B58 <= F17 <= B59
        OR
        B77 <= F17 <= B78
        OR
        B96 <= F17 <= B97
    }
}
The problem (in Excel 2000, at least) is that the custom validation formula field restricts/limits you to 255 characters. If you have Excel 2000, check it out for yourself. Here is a string with 255 characters in it, including the '=' sign. Paste it into any custom data validation field and then try to add more characters; it won't allow it.

Code:
=12345678911234567892123456789312345678941234567895123456789612345678971234567898123456789912345678901234567891123456789212345678931234567894123456789512345678961234567897123456789812345678991234567890123456789112345678921234567893123456789412345678951234
Thank you for your help BobUmlas, and please keep any ideas of how to get around this shortcoming flowing!
-Brian
 
Upvote 0
Then as I said, put the formula in cells, and use the data validation to simply reference the cell.
 
Upvote 0
As Bob suggest, you can refer to cells that contain your formula(s). Another approach is to use Named Formula(s) (Insert>Name>Define). Give if a name. and then enter your formula in the "Refers To" field.

lenze
 
Upvote 0
Thanks very much!!! That worked fine!
Does anyone know if newer versions of excel allow more than 255 characters in the custom data validation field? I couldn't find that tidbit of info anywhere on the net, and was just curious...
 
Upvote 0
Sir, is there a work around for this limitation of 256 characters in the custom data validation? I am using office 365 and I worked on building an attendance sheet with all the required validation checks but i still have to include two more conditions and my formula is exceeding the 256 limit. Please help.
 
Upvote 0
is there a work around for this limitation of 256 characters in the custom data validation?
Not that I'm aware of, as has been said in this thread, you will need to put the formula in a cell
 
Upvote 0
Sir, i am sharing additional context of the work im doing. I have created this attendance tracking file and it already has data validation conditions. Now i have to include a condition to check - if the date is Sunday, if someone applies leave for the days before and after Sunday, then Sunday should allow users to mark as leave and nothing else. I have attached a screenshot of the format of the file. Please help how i can put the formula in a cell for this case.
 

Attachments

  • Screenshot 2022-02-26 100704 (1).jpg
    Screenshot 2022-02-26 100704 (1).jpg
    166.6 KB · Views: 27
Upvote 0

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