Cut & past

Manolocs

Active Member
Joined
Mar 28, 2008
Messages
340
Hi, I have two columns with text. some of the rows has a (text) in front of the text, is there a way to move this (text) to the end of the text of the other column?
[TABLE="width: 10"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[/TR]
[TR]
[TD](1)One[/TD]
[TD]One[/TD]
[/TR]
[TR]
[TD](car) Red[/TD]
[TD]Red[/TD]
[/TR]
[TR]
[TD](above)blue[/TD]
[TD]Something [/TD]
[/TR]
</tbody>[/TABLE]

The result I need is:


[TABLE="width: 10"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[/TR]
[TR]
[TD]One[/TD]
[TD]One (1)[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]Red (car)[/TD]
[/TR]
[TR]
[TD]blue[/TD]
[TD]Something(above)[/TD]
[/TR]
</tbody>[/TABLE]


thanks in advance:)
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Try:
Code:
Sub Test()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim rng As Range
    Dim val As String
    For Each rng In Range("A1:A" & LastRow)
        val = Split(rng, ")")(0)
        rng.Offset(0, 1) = rng.Offset(0, 1) & val & ")"
        rng = Mid(rng, WorksheetFunction.Find(")", rng) + 1, 999)
    Next rng
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
See if this non-looping code does what you want...
Code:
[table="width: 500"]
[tr]
	[td]Sub MoveTextInParenthesesFromColumnAtoColumnB()
  Dim LastRow As Long
  LastRow = Cells(Rows.Count, "A").End(xlUp).Row
  Range("B1:B" & LastRow) = Evaluate(Replace("IF(B1:B#="""","""",B1:B#&"" ""&LEFT(A1:A#,FIND("")"",A1:A#&"")"")))", "#", LastRow))
  Columns("A").Replace ") ", ")", xlPart
  Columns("A").Replace "*)", "", xlPart
End Sub[/td]
[/tr]
[/table]
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top