VBA Find and copy text with parentheses in a range of columns to new cell and clear old data

BHW010116

New Member
Joined
Jun 25, 2018
Messages
1
I am trying to figure out a way to search a range of columns for any thing that starts with an open parentheses and ends with a closing parentheses. Copy that data into one cell and then remove that txt from the original cells. I would prefer to do this using VBA instead of a formula but I am not sure how to get this to work. Any ideas? I posted what my data currently looks like and what I am trying to get my data to look like.

ABCDE
W & VDO NOT RUN WITHOUT AIRFLOW(MUST SEND 07H0105-01WITH UNIT 2PCS PER)
W & VDO NOT RUN WITHOUT AIRFLOW(MUST SEND 07H0105-01WITH UNIT 2PCS PER)
650W 120VDO NOT RUN WITHOUT AIRFLOW(THIS ETCH IS CORRECT) Watts
1000W 120V"DO NOT RUN WITHOUT AIRFLOW"(SEND TO HDA FOR HARDWARE)
3000W 230V"DO NOT RUN WITHOUT AIRFLOW"(SEND BACK TO HDA FORCOMPLETION)
NECKDOWN AREA/ETCH AS CLOSE TOBOTTOM OF UNIT AS POSSIBLE/(SEND UNIT TO SLCTTO BE FINISHED)
Company"DO NOT RUN WITHOUT AIRFLOW"(send UnitTo SLCT toBe Finished)

<tbody>
</tbody>
















ABCDEF
W & VDO NOT RUN WITHOUT AIRFLOW(MUST SEND 07H0105-01 WITH UNIT 2PCS PER)
W & VDO NOT RUN WITHOUT AIRFLOW(MUST SEND 07H0105-01 WITH UNIT 2PCS PER)
650W 120VDO NOT RUN WITHOUT AIRFLOWWatts(THIS ETCH IS CORRECT)
1000W 120V"DO NOT RUN WITHOUT AIRFLOW"(SEND TO HDA FOR HARDWARE)
3000W 230V"DO NOT RUN WITHOUT AIRFLOW"(SEND BACK TO HDA FOR COMPLETION)
NECKDOWN AREA/ETCH AS CLOSE TOBOTTOM OF UNIT AS POSSIBLE/(SEND UNIT TO SLCT TO BE FINISHED)
company Do not run without airflow (SEND UNIT TO SLCT TO BE FINISHED)

<tbody>
</tbody>
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Give this macro a try...
Code:
[table="width: 500"]
[tr]
	[td]Sub CombineAndMoveTextInParentheses()
  Dim R As Long, LastCol As Long, Txt() As String
  LastCol = Cells.Find("*", , xlFormulas, , xlByColumns, xlPrevious, , , False).Column
  For R = 1 To Cells(Rows.Count, "A").End(xlUp).Row
    Txt = Split(Replace(Application.Trim(Join(Application.Index(Range(Cells(R, "C"), Cells(R, LastCol)).Value, 1, 0))), ")", "("), "(")
    Range(Cells(R, "C"), Cells(R, LastCol)).Clear
    Cells(R, "C").Value = Application.Trim(Txt(0) & " " & Txt(2))
    Cells(R, LastCol + 1) = "(" & Txt(1) & ")"
  Next
End Sub[/td]
[/tr]
[/table]
 
Upvote 0

Forum statistics

Threads
1,216,030
Messages
6,128,407
Members
449,448
Latest member
Andrew Slatter

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