Split addresses into address parts with VBA in Excel



Split addresses into address parts with VBA in Excel. Split address into street address, city , province and postal code. Check out my online courses www.easyexcelanswers.com/courses.html
All my courses include online support and a user manual
Let me teach you the VBA that I have learn in my five years of consulting

Let’s take the frustration out of user forms

Become an Affiliate and earn 25% on Course Sales

For more help visit my website www.easyexcelanswers.com or email me at easyexcelanswers@gmail.com.

Contact me regarding customizing this template for your needs.

Click for online Excel Consulting

I am able to provide online help on your computer at a reasonable rate.

I use a Blue condenser Microphone to record my videos, here is the link

Check out Crowdcast for creating your webinars

I use Tube Buddy to help promote my videos
Check them out

Follow me on Facebook

TWEET THIS VIDEO

Follow me on twitter
easyexcelanswers

IG @barbhendersonconsulting

You can help and generate a translation to you own language

*this description may contain affiliate links. When you click them, I may receive a small commission at no extra cost to you. I only recommend products and services that I’ve used or have experience with.

Templates with code are available for $50 USD

code
Sub splitaddress()
Dim address As String
Dim street As String
Dim city As String
Dim prov As String
Dim postc As String
Dim intPos, secpos As Integer
Dim thrd As Long
Dim r As Integer

Worksheets(“sheet1”).Select
r = 2

Do While r (is less than) 242
address = Sheet1.Cells(r, 2)

intPos = InStr(address, “,”) ‘ find the comma
street = Left(address, intPos) ‘address is what ever comes before the first comma
secpos = InStr(intPos + 1, address, “,”) ‘find the second comma
diff = secpos – intPos ‘calculate the number of spaces between the first and the second comma
city = Mid(address, intPos + 1, diff) ‘allow for comma and a space
postc = Right(address, 7) ‘ take seven charaters from the right side of the cell
thrd = InStr(secpos + 1, address, “,”) ‘looking for the third comma
prov = Mid(address, secpos + 1, 3) ‘find the provices

Sheet1.Cells(r, 3) = street
Sheet1.Cells(r, 4) = city
Sheet1.Cells(r, 5) = prov
Sheet1.Cells(r, 6) = postc
r = r + 1
Loop

End Sub

Watch more new videos about Excel Office | Synthesized by Mindovermetal English

Rate this post

Bài viết liên quan

Theo dõi
Thông báo của
guest
0 Comments
Phản hồi nội tuyến
Xem tất cả bình luận