Formatting content of a cell

harpreetgujral

New Member
Joined
Oct 30, 2010
Messages
6
Hi Experts,

Is it possible to identify a seaprate line/vbnewline in a cell text.

Example i have the following text in Cell A1:

"I have a brown dog

I also have a black car

I have a nice watch"


If i have the above text in the cell, then i would like to identify from where is the next line starting. Since that will help me seaprate the first line from the other two.

Thanks
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
can I assume that new line starts with "I"

in that case use data-texttocolumn
fixed wideh
draw a line before every I
 
Upvote 0
Hi Venkat,
The idea to identify these breaks and then utilize the text between these breaks for further formatting through a macro.
 
Upvote 0
Try:
Rich (BB code):

Sub Test()
  
  Dim a, x
  
  ' Put each line of A1 text into zero based array a()
  a = Split([A1], vbLf)
  
  ' Test each line in a()
  For Each x In a
    If Len(x) > 1 Then Debug.Print x
  Next
  
End Sub

You can use also InStr(1,[a1],vbLf) to find line-feed position
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,488
Messages
6,125,092
Members
449,206
Latest member
ralemanygarcia

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