ExceLoki
Well-known Member
- Joined
- Dec 13, 2021
- Messages
- 538
- Office Version
- 365
- Platform
- Windows
Going to start off by stating, VBA is nto my strong suit. What I'm trying to do is have a script that will edit the values in the "ZIP" column of this table i'm working in. My data range can be anywhere from 200-6000 lines. I would like it to edit the first cell and then go to the next until there are no more.
The formula I came up with to get what I am looking for is below:
My input is in column A and desired results in column B
-------------------
The formula I came up with to get what I am looking for is below:
Excel Formula:
=IFS(LEN(create_users_20221122_1134323[@Zip])=5,create_users_20221122_1134323[@Zip],RIGHT(create_users_20221122_1134323[@Zip],4)="0000",LEFT(create_users_20221122_1134323[@Zip],5),LEN(create_users_20221122_1134323[@Zip])=10,TEXTJOIN("-",TRUE,LEFT(create_users_20221122_1134323[@Zip],5),RIGHT(create_users_20221122_1134323[@Zip],4)))
My input is in column A and desired results in column B
-------------------
fix zip codes.xlsm | ||||
---|---|---|---|---|
A | B | |||
1 | Zip | formula | ||
2 | 30506 | 30506 | ||
3 | 0 | #N/A | ||
4 | 04571 | 04571 | ||
5 | 29926 2272 | 29926-2272 | ||
6 | 22201 1701 | 22201-1701 | ||
7 | 19072 0000 | 19072 | ||
8 | 22027 0000 | 22027 | ||
9 | 32163 0000 | 32163 | ||
10 | 21045 2529 | 21045-2529 | ||
11 | 33414 6245 | 33414-6245 | ||
12 | 11768 | 11768 | ||
13 | 10025 | 10025 | ||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B2:B13 | B2 | =IFS(LEN(Table3[@Zip])=5,Table3[@Zip],RIGHT(Table3[@Zip],4)="0000",LEFT(Table3[@Zip],5),LEN(Table3[@Zip])=10,TEXTJOIN("-",TRUE,LEFT(Table3[@Zip],5),RIGHT(Table3[@Zip],4))) |