Extracting Text from a string in a Cell (Excel VBA)

jimmynora

New Member
Joined
Oct 20, 2010
Messages
27
I have a range of cells that contains data in the form on strings. I need to extract a part of this string and paste it (to the empty cell on the right).

Range "AV" contains the cells with strings
I need to extract the data between "0" OR "0:" and till the end of the string in the cell OR till "1"

Can anyone show me how to do this with a Macro (VBA code) or anyway else ? Thank You

example :

(String in a cell)

shawn012k
0: james
pdf: 321
1:
pdf:
2:
pdf:

Extracted Data (pasted in the cell to the right): james
pdf: 321
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
In the case of 0:, would you need to keep the : (unclear from your example)
 
Upvote 0
oooh, oooh, I know this one.....

is it...
Code:
B1:
=TRIM(REPLACE(LEFT(A1;FIND(CHAR(10)&"1:";A1&CHAR(10)&"1:")-1);1;FIND("0:";A1&"0:")+1;""))
wrap text activated
?

Course, might've copied that from another forum.
 
Upvote 0
That's very helpful. Unfortunately I appear to have misplaced my crystal ball - in the meantime perhaps you could provide some more information ?

Excel Workbook
AB
1shawn012k 0: jamespdf: 3211:pdf: 2: pdf:jamespdf: 321
2shawn012k 0: james ajskajskjaksj kajsaksjaksjakjsa pdf: 321asklakslalskl1:pdf:james ajskajskjaksj kajsaksjaksjakjsa pdf: 321asklakslalskl
3askajskajsak
Sheet4


In the above UK delimiters (and function name) are used.
 
Upvote 0
Is there anyway I can further manipulate this formula to trim only the part between "1" or "1:" and "2:" or "end of cell" ?

In this case I need to ignore the first 1: because it occurs before the 0:

example:

user bio1:
0: asdasdas
1: asdasds
2:
3: asdas

required data:
asdasds
 
Upvote 0

Forum statistics

Threads
1,215,537
Messages
6,125,389
Members
449,222
Latest member
taner zz

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