1 min readfrom Microsoft Excel | Help & Support with your Formula, Macro, and VBA problems | A Reddit Community

How to create a macro that removes unnecessary digits in zip code?

Hello all! I format lots of files per day and would like to create a macro that automates most of it. I'm aware that using "Text to Columns" with a specific fixed width and then not importing the second half works to remove the extra four digits, but can't figure out how I would go about coding that. The recording process does not work, unfortunately.

For context, I've included an example of what the zips might look like- all zips should end up in a 5 digit format, with leading zeroes if the zip is only 4 digits. The zip codes will always be in the N column, and the left and right columns also have data in them. As you can see, nine digit zip codes may be in 00000-0000 or 000000000 or 00000 0000. I've tried reformatting all zips to be 00000-0000 with the zeroes trailing for 5 digit zips, but I cant seem to use the delimited option in text to columns to get rid of the extra ones either. Any advice appreciated!

https://preview.redd.it/jyphzamf4lig1.png?width=1144&format=png&auto=webp&s=b3cf7ad30618cc2b788d2c9c459e8e56ee6110f4

submitted by /u/ImportantDress7777
[link] [comments]

Want to read more?

Check out the full article on the original site

View original article