Try it on your table on top of your drawing
I could't to write BubbleSort for whole text but
with separate text columns this will work I hope
See prompts inside the code
[code]
Option Explicit
Sub FieldsToTable()
Dim oSsets As AcadSelectionSets
Dim oSset As AcadSelectionSet
Dim oTable As AcadTable
Dim i, j, k, l, m, n As Long
Dim ftype(0) As Integer
Dim fData(0) As Variant
Dim insPt As Variant
Dim tmpStr As String
ftype(0) = 0: fData(0) = "TEXT"
MsgBox "NOTE:" & vbCrLf & _
"Select by window every text column" & vbCrLf & _
"separatelly: from top to bottom" & vbCrLf & _
"and from left to right", vbExclamation
Set oSsets = ThisDrawing.SelectionSets
For Each oSset In oSsets
If oSset.Name = "$axss$" Then
oSset.Delete
End If
Next
Set oSset = oSsets.Add("$axss$")
Dim wPoint1 As Variant
Dim wPoint2 As Variant
Dim unitText As Object
k = CLng(InputBox("Enter the number of columns", "Table parameters", 5))
insPt = ThisDrawing.Utility.GetPoint(, "Table insertion point")
n = 1
l = 0
While n < k + 1
m = 3
wPoint1 = ThisDrawing.Utility.GetPoint(, "Specify first corner point of " & CStr(n) & " column")
wPoint2 = ThisDrawing.Utility.GetCorner(wPoint1, "Specify opposite corner:")
oSset.Select acSelectionSetWindow, wPoint1, wPoint2, ftype, fData
If n = 1 Then
i = oSset.Count
Set oTable = ThisDrawing.ModelSpace.AddTable(insPt, i + 3, k, 7.5, 15#)
oTable.RecomputeTableBlock False
oTable.SetTextHeight 1, 1.6875
oTable.TitleSuppressed = True
oTable.HeaderSuppressed = True
m = 0
l = 0
tmpStr = "NO"
oTable.SetText m, l, tmpStr
oTable.SetCellAlignment m, l, acMiddleCenter
m = 0
l = 1
tmpStr = "Q1"
oTable.SetText m, l, tmpStr
oTable.SetCellAlignment m, l, acMiddleCenter
m = 1
l = 0
tmpStr = "NO"
oTable.SetText m, l, tmpStr
oTable.SetCellAlignment m, l, acMiddleCenter
m = 1
l = 1
tmpStr = "Q"
oTable.SetText m, l, tmpStr
oTable.SetCellAlignment m, l, acMiddleCenter
Dim hdrArr As Variant
hdrArr = Array("Q2", "A", "B", "C", "D")
m = 2
For l = 0 To UBound(hdrArr)
tmpStr = hdrArr(l)
oTable.SetText m, l, tmpStr
oTable.SetCellAlignment m, l, acMiddleCenter
Next l
l = 0
m = 3
End If
Dim txtArr() As Variant
ReDim Preserve txtArr(oSset.Count - 1, 1)
For i = 0 To oSset.Count - 1
Set unitText = oSset.Item(i)
txtArr(i, 0) = unitText.InsertionPoint
txtArr(i, 1) = unitText.ObjectID
Next
txtArr = SortObjectsByRow(txtArr)
For i = 0 To UBound(txtArr, 1)
tmpStr = CStr(txtArr(i, 1))
tmpStr = "%<\AcObjProp Object(%<\_ObjId " & tmpStr & _
">%).TextString \f" & " " & "" & "%bl2" & "" & ">%"
oTable.SetText m, l, tmpStr
oTable.SetCellAlignment m, l, acMiddleCenter
m = m + 1
Next i
l = l + 1
n = n + 1
oSset.Clear
Erase txtArr
Wend
oTable.RecomputeTableBlock True
MsgBox "Mattew 4:14" & vbCrLf & _
"The people who set in darkness" & vbCrLf & _
"have seen a light...", vbExclamation
End Sub
'@'~~~~~~~~~~~written by Fatty T.O.H~~~~~~~~~~~~~~~~'@'
Public Function SortObjectsByRow(ByVal sourceArr As Variant)
Dim OnCondition As Boolean
Dim Depot(0, 1) As Variant
Dim Enumer As Long
OnCondition = False
Do Until OnCondition
OnCondition = True
For Enumer = LBound(sourceArr) To UBound(sourceArr) - 1
If sourceArr(Enumer, 0)(1) < sourceArr(Enumer + 1, 0)(1) Then
Depot(0, 0) = sourceArr(Enumer, 0)
Depot(0, 1) = sourceArr(Enumer, 1)
sourceArr(Enumer, 0) = sourceArr(Enumer + 1, 0)
sourceArr(Enumer, 1) = sourceArr(Enumer + 1, 1)
sourceArr(Enumer + 1, 0) = Depot(0, 0)
sourceArr(Enumer + 1, 1) = Depot(0, 1)
OnCondition = False
End If
Next
Loop
SortObjectsByRow = sourceArr
End Function
[/code]
Fatty
~'J'~