ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What are the character codes of a carriage return entered in a comment? (https://www.excelbanter.com/excel-programming/335834-what-character-codes-carriage-return-entered-comment.html)

John Wirt[_11_]

What are the character codes of a carriage return entered in a comment?
 
I need to rewrite a filter that takes regular CR-LF (Chr(13)Chr(10)
characters out of all the comments on a page but leaves carriage returns
entered in typing in the comment.

The latter are apparently NOT the regular vbCRLF pair of characters. I have
written a filter that distinguishes between the two types of carriage
returns by using the vbCRLF constant in a SEARCH worksheet function, but I
also need to detect whether any "soft returns" are included in a comment and
count them. This is necessary in order to know how to size the comment after
filtering it. (The procedure both resizes and changes the shape of the
comment.)

So my question is, what are the characters entered into a comment when one
(manually) types a carriage return into a comment using Insert Comment.

The vbCRLF comments are imbedded in imported text that is used in creating
many of the comments on a page using a VBA procedure.

So the question is, what is the code sequence of the carriage return typed
in when one hits Enter in inserting a comment into a spreadsheet?

Thank you.

John Wirt



David McRitchie

What are the character codes of a carriage return entered in a comment?
 
Hi John,
Basically Excel only uses CHAR(10) which is LF (line feed)
so in VBA you would replace vbCRLF with vbLF
then count your vbLF

When you hit Alt+Enter you are generating vbLF
or CHR(10)
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"John Wirt" wrote in message ...
I need to rewrite a filter that takes regular CR-LF (Chr(13)Chr(10)
characters out of all the comments on a page but leaves carriage returns
entered in typing in the comment.

The latter are apparently NOT the regular vbCRLF pair of characters. I have
written a filter that distinguishes between the two types of carriage
returns by using the vbCRLF constant in a SEARCH worksheet function, but I
also need to detect whether any "soft returns" are included in a comment and
count them. This is necessary in order to know how to size the comment after
filtering it. (The procedure both resizes and changes the shape of the
comment.)

So my question is, what are the characters entered into a comment when one
(manually) types a carriage return into a comment using Insert Comment.

The vbCRLF comments are imbedded in imported text that is used in creating
many of the comments on a page using a VBA procedure.

So the question is, what is the code sequence of the carriage return typed
in when one hits Enter in inserting a comment into a spreadsheet?

Thank you.

John Wirt





davidm

What are the character codes of a carriage return entered in a comment?
 

David,

In VBA, I have long fallen into the habit of using the followin
interchangeably to move to the next line:

* Chr(10)*
* Chr(13)*
*VbCrLf*
*VbCr*
*VBLf*
*VbNewLine *

Have I taken too much for granted

--
david
-----------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...fo&userid=2064
View this thread: http://www.excelforum.com/showthread.php?threadid=39116


David McRitchie

What are the character codes of a carriage return entered in a comment?
 
At least on a windows machine, within Excel, I'd say yes.

For Char(13) you would see a square bullet as an unprintable
character, and if you don't have cell wrap on in a cell your
would also see it for Char(10). Alt+Enter gets you an automatic
cell wrap without you having to turn it on in cell, format

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"davidm" wrote in message
...

David,

In VBA, I have long fallen into the habit of using the following
interchangeably to move to the next line:

* Chr(10)*
* Chr(13)*
*VbCrLf*
*VbCr*
*VBLf*
*VbNewLine *

Have I taken too much for granted?


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=391164




Norman Jones

What are the character codes of a carriage return entered in a comment?
 
Hi David,

Try this demo:

Public Sub TestLineFeeds()

Dim Arr As Variant, arr2 As Variant
Dim i As Long

Arr = Array(Chr(10), vbLf, Chr(13), vbCr, vbNewLine, _
vbCr + vbLf, vbCrLf, vbLf + vbCr)

arr2 = Array("Chr(10)", "vbLf", "Chr(13)", "vbCr", "vbNewLine", _
"vbCr + vbLf", "vbCrLf", "vbLf + vbCr")
For i = LBound(Arr) To UBound(Arr)
Cells(i + 1, 1).Value = "Norman" & Arr(i) & "Jones"
Cells(i + 1, 2) = arr2(i)
Next i

End Sub

---
Regards,
Norman



"davidm" wrote in
message ...

David,

In VBA, I have long fallen into the habit of using the following
interchangeably to move to the next line:

* Chr(10)*
* Chr(13)*
*VbCrLf*
*VbCr*
*VBLf*
*VbNewLine *

Have I taken too much for granted?


--
davidm
------------------------------------------------------------------------
davidm's Profile:
http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=391164





All times are GMT +1. The time now is 12:18 AM.

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