Hello,
My apologies for the delayed response. Your macro works about 1/2 the time. Sometimes I get a "Run-time Error '9': Subscript out of range". When I step into the VBA the MyArray(Count, Pos) = T is highlighted. So I assume it's getting hung up there. Can you assist? Thanks.
Sub SWMRIC()
'
' SWMRIC Macro
'
With ActiveSheet.UsedRange
SR = .Row
SC = .Column
LR = .Rows(UBound(.Value)).Row
LC = .Columns(UBound(.Value, 2)).Column
End With
'Write Titles
Titles = Array("Name", "Company", "Tel.1", "Tel.2", "Email", "See.1", "See.2", "Member Of:")
Range("B2:I2").Value = Titles
'How Many Entries do we have?
Entries = Application.WorksheetFunction.CountIf(Range("A:A"), "*@*")
ReDim MyArray(Entries - 1, 7)
'Read Data into VBA
InputA = Range(Cells(SR, SC), Cells(LR, SC)).Value
StartPos = 1
'We need to do this for every Entry.
For Count = 0 To Entries - 1
Pos = 0
TFlag = 0
EndPos = Range(Cells(StartPos + 1, 1), Cells(LR, 1)).Find("Member Of ", LookIn:=xlValues, Lookat:=xlPart).Row - 1
'We need to do this for every line of the entry.
For Count2 = StartPos To EndPos
T = InputA(Count2, 1)
If InStr(T, "@") > 0 Then MyArray(Count, 4) = T: GoTo Skip
If Left(T, 1) = "(" Then MyArray(Count, 2 + TFlag) = T: TFlag = 1: GoTo Skip
If Left(T, 9) = "Member of" Then MyArray(Count, 7) = T: GoTo Skip
MyArray(Count, Pos) = T: Pos = Pos + 1: If Pos = 2 Then Pos = 5
Skip:
Next
StartPos = EndPos + 1
Next
'Save The Sorted Data to Spreadsheet
Range("B3:I" & Entries + 2).Value = MyArray
End Sub
Bookmarks