Removing text outside the <<...>> brackets

danish6061

New Member
Joined
Mar 16, 2020
Messages
43
Office Version
2016
Platform
Windows
Hi, I have a question,
I have a word document which is in arabic, the file has a lot of text that I have placed between the following brackets: «............» Is there any way i can delete ALL the text in the document and just preserve whats between these two brackets?
Please help me... Thanks
 

Some videos you may like

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

goesr

Well-known Member
Joined
Nov 15, 2013
Messages
635
Hello danish69061. As nobody has responded I thought I would give you some code that might help you get started. This is done for excel using a phrase in cell A1 and puts the contents inside the brackets in Cell A2. Hope this helps you get started. Try this on a sample spreadsheet first.

VBA Code:
Sub CopyInside()
Dim Start1 As Integer
Dim Stop1 As Integer
Start1 = InStr(1, Cells(1, 1).Value, "<<", vbBinaryCompare)
Stop1 = InStr(1, Cells(1, 1).Value, ">>", vbBinaryCompare)
copylength = Stop1 - Start1

Dim strLen As Integer
strLen = Len(Cells(1, 1).Value)
String1 = Left(Right(Cells(1, 1).Value, strLen - Start1 - 2), copylength - 3)

Cells(2, 1).Value = String1

End Sub
 

danish6061

New Member
Joined
Mar 16, 2020
Messages
43
Office Version
2016
Platform
Windows
Thankss Goesr for reply... But really it does'nt work. Could you suggest me something better!
 

Macropod

Retired Moderator
Joined
Aug 27, 2007
Messages
3,445
I thought I would give you some code that might help you get started. This is done for excel using a phrase in cell A1 and puts the contents inside the brackets in Cell A2.
That's all very well but, as the OP said clearly enough:
I have a word document which is in arabic, the file has a lot of text that I have placed between the following brackets: «............»
@ danish6061 - you could insert:
»
at the start of the document, and:
«
at the end of the document, then use a wildcard Find/Replace, where:
Find = »*«
Replace = ^p
 

goesr

Well-known Member
Joined
Nov 15, 2013
Messages
635
Macropod - Great idea. I think you can help danish6061 in the future. I'm sorry my solution was not up to your standards. As nobody else had responded, I hoped this could get him started. I would like to see your code to solve the problem so that both danish6061 and I could see how it is done.
 

Watch MrExcel Video

Forum statistics

Threads
1,102,565
Messages
5,487,591
Members
407,605
Latest member
PACULA

This Week's Hot Topics

Top