Custom Data Validation Help

jgeorg0310

New Member
Joined
Aug 7, 2017
Messages
4
Hi,

I am trying to create a custom data validation and I need some help with the formula syntax. In my spreadsheet Column B has a drop down that says "Refund" and "Charge". I want to create the custom data validation in Column D to limit the number of characters in the cell so that any line that has "Refund" selected is limited to only 4 numbers and any line with "Charge" selected is limited to 15 or 16 numbers. Any assistance would be much appreciated! Thanks!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
I only tested this with B2/B3 & D2/D3, but it should do the job:

Code:
=IF($B2="Refund",LEN($D2)=4,IF($B2="Charge",AND(LEN($D2)>14,LEN($D2)<17),""))

$B2 & $D2 will need to be changed to the first row you are applying the data validation to. So, if the first row is B11/D11, then the formula applied to the entire range would be:

Code:
=IF($B11="Refund",LEN($D11)=4,IF($B11="Charge",AND(LEN($D11)>14,LEN($D11)<17),""))
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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