This repository has been archived by the owner on Dec 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
addrBreakdown.bas
67 lines (51 loc) · 1.67 KB
/
addrBreakdown.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Attribute VB_Name = "addrBreakdown"
Sub addrBreakdown()
Dim PICK_WB, PICK_WS, A_CELL, CITYCELL, STATECELL, ZIPCODECELL, COUNTRYCELL As String
'initialize vars
PICK_WS = "Arkansas Firms"
A_CELL = "A2"
CITYCELL = ""
STATECELL = "AR"
ZIPCODECELL = ""
COUNTRYCELL = "USA"
'initialize worksheet
ActiveSheet.Range(A_CELL).Select
'loop through page till empty cell in A column
Do Until IsEmpty(ActiveCell) And IsEmpty(ActiveCell.Offset(1, 0))
'select address cell
ActiveCell.Offset(1, 1).Select
'copy address data
CITYCELL = ActiveCell.Value
STATECELL = ActiveCell.Value
ZIPCODECELL = ActiveCell.Value
'copy country
ActiveCell.Offset(1, 0).Select
COUNTRYCELL = ActiveCell.Value
'Move to new address location
ActiveCell.Offset(-2, 1).Select
CITYCELL = Trim(CITYCELL)
CITYCELL = Left(CITYCELL, Len(CITYCELL) - 10)
ActiveCell.Value = CITYCELL
'Move to new state location
ActiveCell.Offset(0, 1).Select
STATECELL = Trim(STATECELL)
STATECELL = Left(STATECELL, Len(STATECELL) - 6)
STATECELL = Right(STATECELL, 2)
ActiveCell.Value = STATECELL
'Move to new zip location
ActiveCell.Offset(0, 1).Select
ZIPCODECELL = Trim(ZIPCODECELL)
ZIPCODECELL = Right(ZIPCODECELL, 5)
ActiveCell.Value = ZIPCODECELL
'Move to new country location, set to Merica
ActiveCell.Offset(0, 1).Select
COUNTRYCELL = Trim(COUNTRYCELL)
ActiveCell.Value = COUNTRYCELL
'move to delete rows
ActiveCell.Offset(1, -5).Select
Rows(ActiveCell.Row).Delete Shift:=xlUp
Rows(ActiveCell.Row).Delete Shift:=xlUp
'move to next entry
'ActiveCell.Offset(2, 0).Select
Loop
End Sub