Hello!
I have some macro:
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 I want 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"](yes)(no)(don't know)<strike></strike>
[/TD]
[TD="align: center"]yes
[/TD]
[TD="align: center"]no
[/TD]
[TD="align: center"]don't know<strike></strike>
[/TD]
[/TR]
[TR]
[TD="align: center"]2
[/TD]
[TD="align: center"](yes)(no)<strike></strike>
[/TD]
[TD="align: center"]yes
[/TD]
[TD="align: center"]no
[/TD]
[TD="align: center"]-no-
[/TD]
[/TR]
[TR]
[TD="align: center"]3
[/TD]
[TD="align: center"](yes)<strike></strike>
[/TD]
[TD="align: center"]yes
[/TD]
[TD="align: center"]-no-<strike></strike>
[/TD]
[TD="align: center"]-no-<strike></strike>
[/TD]
[/TR]
</tbody>[/TABLE]
Help me please!
I have some macro:
Code:
Sub bracketsSub()
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) = brackets(CStr(arr(x, 1)))
Next x
Cells(1, 1).Resize(UBound(arr, 1), UBound(arr, 2)).Value = arr
Erase arr
End Sub
Private Function brackets(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, ")")
brackets = Mid(sss, aaa + 1, bbb - aaa - 1)
Exit Function
Error_handler:
brackets = "-no-"
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 I want 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"](yes)(no)(don't know)<strike></strike>
[/TD]
[TD="align: center"]yes
[/TD]
[TD="align: center"]no
[/TD]
[TD="align: center"]don't know<strike></strike>
[/TD]
[/TR]
[TR]
[TD="align: center"]2
[/TD]
[TD="align: center"](yes)(no)<strike></strike>
[/TD]
[TD="align: center"]yes
[/TD]
[TD="align: center"]no
[/TD]
[TD="align: center"]-no-
[/TD]
[/TR]
[TR]
[TD="align: center"]3
[/TD]
[TD="align: center"](yes)<strike></strike>
[/TD]
[TD="align: center"]yes
[/TD]
[TD="align: center"]-no-<strike></strike>
[/TD]
[TD="align: center"]-no-<strike></strike>
[/TD]
[/TR]
</tbody>[/TABLE]
Help me please!