Page 1 of 1

extract code by column wise

Posted: Sat Jan 02, 2021 11:19 am
by sna
Hi Dear
I need to extract text within brackets to multiple column.
I have listed result starts from column AC.
But the actual result I would need in column B onward.

I add a code below but work only one column


Thanks

Re: extract code by column wise

Posted: Sat Jan 02, 2021 11:27 am
by sna

Code: Select all

Sub Extract()
Dim Rng As Range,Dn As Range,Sp As Variant
Set Rng=Range("A2",Range("A"&Rows.Count).End(xlUp))
For Each Dn in Rng
Sp=Split(Dn.Value,"(")
If Ubound(Sp)>0 Then
Dn.offset(,1).Value=Left(Sp(1), Len(Sp(1)) - 1)
End if
Next 
End Sub

Re: extract code by column wise

Posted: Sat Jan 02, 2021 7:12 pm
by snasui
:D Please attach file with code inside again for easy to be testing.

Re: extract code by column wise

Posted: Sat Jan 02, 2021 9:37 pm
by sna
Thanks for your prompt response.
Here's an attachment


Thanks

Re: extract code by column wise

Posted: Sat Jan 02, 2021 9:52 pm
by snasui
:D The example code is below:

Code: Select all

'Other code
Sp = Split(Dn.Value, ")")
If UBound(Sp) > 0 Then
  Dn.Offset(, 1).Value = Mid(Sp(0), 2)
  Dn.Offset(, 2).Value = Sp(1)
End If
'Other code

Re: extract code by column wise

Posted: Mon Jan 04, 2021 10:03 pm
by sna
Hi Dear

It works for the first part another no work like in the columns highlight yellow


Thanks

Re: extract code by column wise

Posted: Mon Jan 04, 2021 10:51 pm
by snasui
:D You can adjust code like this:

Code: Select all

'Other code
Dim i As Integer
Set rng = Range("A2", Range("A" & Rows.Count).End(xlUp))
For Each Dn In rng
    Sp = Split(Dn.Value, ")")
    For i = LBound(Sp) To UBound(Sp) - 1
       Dn.Offset(0, i + 1).Value = Split(Sp(i), "(")(1)
    Next i
Next Dn
'Other code

Re: extract code by column wise

Posted: Tue Jan 05, 2021 7:27 am
by sna
Thanks it worked flawlessly