View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson[_2_] Dave Peterson[_2_] is offline
external usenet poster
 
Posts: 420
Default VBA part of cell content

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" 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]



On Mon, 10 May 2010 00:35:18 +0200, "Jack Sons"
wrote:


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





--

Dave Peterson