Thanks Dave.
I did my last posting at 02.05 AM, so I went to bed and saw your answer
just now. Once in bed I realized that I could have explained myself much
better by simply saying that I wanted to do something with the third
line in the cell, but I was focused too much at the cornerstones of the
third line, the chr(10)'s. These are needed of course to determine
what's on that third line. Stupid that I didn't think of an InStr in an
InStr. I'm sorry, too late at night I guess.
Question 1:
Is the number of possible "nested" InStr's unlimited?
Question 2:
You wrote "... if that length portion was greater than 0". Did you mean
wether the third line contains any characters - other than (the third)
chr(10)?
Jack.
"Dave Peterson" <
[email protected]> schreef in bericht
Option Explicit
Sub testme()
Dim FirstPos As Long
Dim SecondPos As Long
Dim myCell As Range
Set myCell = ActiveSheet.Range("A1")
FirstPos = InStr(1, myCell.Value, vbLf, vbTextCompare)
SecondPos = InStr(FirstPos + 1, myCell.Value, vbLf, vbTextCompare)
myCell.Characters(FirstPos + 1, SecondPos - FirstPos - 1).Font.Bold
= True
End Sub
Excel's VBA is pretty forgiving. It didn't even care if that length
portion was
greater than 0.
Jack Sons wrote:
Thank you Chip.
Problem is, I don't know on what posititions the second chr(10) and
the third chr(10) are. (with chr(10) I mean the character that causes
the content to go on at a new line in the cell) Their positions vary
from cell to cell in the column. The content is like
xxxx...xxxchr(10)xx...xxxxchr(10)xxxxxx...xxchr(10) xxxx etc. The x's
stand for other characters. The number of x's vary from cell to cell.
In this exaple I want to do things wits the xx...xxxx part because it
is between the second chr(10) and the third chr(10). What is the way
to do this with code?
Jack.
"Chip Pearson" <
[email protected]> schreef in bericht
You can modify static text in a cell with code like
Range("A1").Characters(5, 3).Font.Bold = True
This turns characters 5, 6, and 7 bold.
Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]
Hi all,
I want to do something (change font size and font color f.i.) with
the part
of the content of the active cell that is between the second and the
third
chr(10). What code do I need?
I thank you in advance for your advice.
Jack Sons
The Netherlands