Sub ImportFromAddressBook()
Dim newWorkBook As Workbook
Dim pathStr As String
Dim resultRRay As Variant
Dim rNum As Long, outPoint As Long
pathStr = Application.GetOpenFilename
If Not (pathStr = "False") Then
On Error GoTo HaltRoutine
Set newWorkBook = Workbooks.Open(pathStr)
With newWorkBook.Sheets(1).Range("A:A")
With Range(.Cells(1, 1), .Cells(.Rows.Count, 1).End(xlUp))
.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:=":", FieldInfo:=Array(Array(1, 1), Array(2, 1))
End With
ReDim resultRRay(1 To 2, 1 To .Rows.Count)
For rNum = 1 To .Rows.Count
If .Cells(rNum, 1) = "N" Then
outPoint = outPoint + 1
resultRRay(1, outPoint) = .Cells(rNum, 2).Value
End If
If .Cells(rNum, 1) Like "EMAIL*" Then
resultRRay(2, outPoint) = .Cells(rNum, 2).Value
End If
Next rNum
ReDim Preserve resultRRay(1 To 2, 1 To outPoint)
With .Offset(0, 2).Resize(outPoint, 2)
.Value = Application.Transpose(resultRRay)
With .Offset(0, 2)
.Columns(1).FormulaR1C1 = "=SUBSTITUTE(SUBSTITUTE(RC[-2],"";"","", "",1),"";"","""")"
.Columns(2).FormulaR1C1 = "=RC[-2]"
.Value = .Value
End With
Range(.Parent.Range("a1"), .Cells).EntireColumn.Delete
End With
End With
End If
HaltRoutine:
On Error GoTo 0
End Sub