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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
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,214,985
Messages
6,122,605
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