Good evening!
I have some code:
It's extract some text (first found text) from the brackets "[]" from the strings in the "A" column and copy to "B" column.
What I should do to extract all texts from the brackets?
Example want I to get:
[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"][red][pink][green][/TD]
[TD="align: center"]red[/TD]
[TD="align: center"]pink[/TD]
[TD="align: center"]green[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"][black][white][/TD]
[TD="align: center"]black[/TD]
[TD="align: center"]white[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"][blue][/TD]
[TD="align: center"]blue[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]
<strike></strike>
Thanx in advance.
I have some code:
Code:
Sub sqbrackSub()
Dim arr() As Variant
Dim x As Long
x = Cells(Rows.Count, 1).End(xlUp).Row
arr = Cells(1, 1).Resize(x, 2).Value
For x = LBound(arr, 1) To UBound(arr, 1)
arr(x, 2) = sqbrack(CStr(arr(x, 1)))
Next x
Cells(1, 1).Resize(UBound(arr, 1), UBound(arr, 2)).Value = arr
Erase arr
End Sub
Private Function sqbrack(ByRef sss As String) As String
Dim aaa As Long '---
Dim bbb As Long '---
On Error GoTo Error_handler:
aaa = InStr(sss, "(")
bbb = InStr(aaa, sss, ")")
sqbrack = Mid(sss, aaa + 1, bbb - aaa - 1)
Exit Function
Error_handler:
sqbrack = ""
End Function
It's extract some text (first found text) from the brackets "[]" from the strings in the "A" column and copy to "B" column.
What I should do to extract all texts from the brackets?
Example want I to get:
[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"][red][pink][green][/TD]
[TD="align: center"]red[/TD]
[TD="align: center"]pink[/TD]
[TD="align: center"]green[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"][black][white][/TD]
[TD="align: center"]black[/TD]
[TD="align: center"]white[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"][blue][/TD]
[TD="align: center"]blue[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]
<strike></strike>
Thanx in advance.