Removing Repeating Blocks of text

Helen842000

New Member
Joined
Mar 28, 2011
Messages
34
Hi,

I have a very long excel spreadsheet (46K rows) Made up mostly of a repeated text block & then a list of serial numbers, then the same text block and different serial numbers. This repeats over and over. I just want the serial numbers and to remove the text part.

I get an error when I try to do Find & Replace - the error is "formula is too long". I presume this is because the text in the cells is around is two paragraphs.

I presume I'll need to use VBA to clear this repeating text out or use the SUBSTITUTE function.

Can anyone suggest a suitable method?

Thanks!

Example Spreadsheet


Dear Mr Blogs, TEXT BLOCK STARTS XXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
CONTINUES FOR 2 PARAGRAPHS THEN BLOCK ENDS X

XYZ123
LMN052
45195A

Dear Mr Blogs, TEXT BLOCK STARTS XXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
CONTINUES FOR 2 PARAGRAPHS THEN BLOCK ENDS X

912ZZZ
456232

(This repeats around 300 times, I have around 300 blocks of identical text to remove)
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Maybe this?

With your data in A2 Down
In B2
Code:
=IF(LEN(A2)<>6,"",ROW())
Drag/Fill Down

In C2
Code:
=IF(ROWS($1:1)>COUNT(B:B),"",INDEX(A:A,SMALL(B:B,ROWS($1:1))))
Drag/Fill Down until blanks are returned

Copy and paste > paste special > values to your destination if required

Change the IF() condition to suit your code string lengths if they aren't all 6 characters long.
e.g.
Code:
=IF(OR(A2="",LEN(A2)>10),"",ROW())
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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