Find string in certain Cell and edit contents within parenthesis

Range

Board Regular
Joined
Nov 13, 2010
Messages
140
Hi - looking for some help.

Need a snippet of VBA to do the below.


1. Search the contents of Column A for "***FLOP*** [xxxxxx]" where the contents of [ ] will ALWAYS be different.
2. The snippet of code should then split up the contents within the brackets from [xxxxxx] to [xx xx xx].

Thanks
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
38,154
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Give this macro a try...
Code:
Sub FLOP()
  Dim R As Long, Data As Variant, Parts() As String
  Data = Range("A1", Cells(Rows.Count, "A").End(xlUp))
  For R = 1 To UBound(Data)
    If InStr(Data(R, 1), "[") Then
      Parts = Split(Data(R, 1), "[")
      Parts(1) = Format(Parts(1), "@@ @@ @@@")
      Data(R, 1) = Join(Parts, "[")
    End If
  Next
  Range("A1").Resize(UBound(Data)) = Data
End Sub
 
Upvote 0

Range

Board Regular
Joined
Nov 13, 2010
Messages
140
This worked perfectly, however if I wanted an exception for brackets that only contained [xx] would that be possible?

This code is affecting my Turn & River found in this thread http://www.mrexcel.com/forum/excel-questions/857278-merge-strings-single-column.html

(sorry for all the threads, my goal is soo complex the only way I think I can achieve this by the end of the week is to make micro threads and peice the info together myself, and then teach myself about it over the coming months.
 
Upvote 0

Forum statistics

Threads
1,196,018
Messages
6,012,892
Members
441,738
Latest member
dataexcel

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
Top