ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Substring of a Chr(10) delimited cell (https://www.excelbanter.com/excel-programming/347368-substring-chr-10-delimited-cell.html)

peacelittleone[_3_]

Substring of a Chr(10) delimited cell
 

All -

I have a range of cells (C2:C41) that contain 1 to 50 (variant) values
separated by chr(10).

i.e.
C2 = "xyz"
C3 = "xya ghi" (or the result of "xya" & chr(10) & "ghi"

and so on

So, I have in my macro

For Each c In myRange
curr_row = c.Row
curr_col = c.Column

tempString = c.Value
i = Len(tempString) - Len(Replace(tempString, Chr(10), ""))
'i = number of occurences of Chr(10)

For j = 1 To i + 1
curr_marker = InStr(prev_marker, tempString, Chr(10))
'curr_marker = position of current Chr(10)
Cells(curr_row, curr_col + j).Value =
*tempString.Characters(prev_marker, curr_marker - 1)*
prev_marker = curr_marker
Next j

Next c

But as you will notice the tempString.characters doesn't work.

How do I get a substring of tempString starting at position =
prev_marker for a length of curr_marker - prev_marker?

TIA!


--
peacelittleone


------------------------------------------------------------------------
peacelittleone's Profile: http://www.excelforum.com/member.php...o&userid=20937
View this thread: http://www.excelforum.com/showthread...hreadid=490842


peacelittleone[_4_]

Substring of a Chr(10) delimited cell
 

Completely forgot about Mid.


--
peacelittleone


------------------------------------------------------------------------
peacelittleone's Profile: http://www.excelforum.com/member.php...o&userid=20937
View this thread: http://www.excelforum.com/showthread...hreadid=490842



All times are GMT +1. The time now is 10:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com