Set Character limit based on another cell contents

Mattmo

New Member
Joined
Sep 19, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi. I sure hope this is an easy one, but I can't seem to find the answer anywhere.

I have a template that lists addresses and need to make sure that when the country is United States, the Zip Code has 5 digits since state zips with leading zeros are always being dropped. Is there any way to do this using Data Validation formulas? I tried just an if statement but all that did was make ANY info entered in the zip code filed require 5 characters if the country was anything at all, so...that didn't work out. But I'm not incredibly sophisticated with excel formulas so maybe there's a better way?
 

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.
Welcome to the Board!

Have you tried pre-formatting the column holding Zip Code to be Text (instead of General or Number)?
If it is pre-formatted to be Text, it will not drop any leading zeroes which are entered.
 
Upvote 0
Hi, thank you for replying. Yes, I've tried that, and it's helpful! But would like to have some sort of validation to ensure that all US zip codes are 5 digits, as the Zip Code is a requirement for certain tools to work properly.
 
Upvote 0
I think I would probably use VBA to automatically verify that.
What Column is the country code in, and what column is the Zip Code in?
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,620
Latest member
dsubash

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