Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default new line character in cell


Hi
I am using the following piece of code to assign a text to a cell.

Cells(row, col).Value = GetAttribValue(objAttrib, strAttribName)

The function GetAttribValue returns a simple VB string that contains
some vbCrLf 's (new line characters).

I find that the text that actually gets displayed in the cell actually
contains some extra vbCr or vbLf characters inserted just before the
original vbCrLf. I am not sure how excel inserts these extra
characters by itself.

How can I avoid this problem.

Thanks for any help.

Regards
Nitesh Gupta


--
xgnitesh
------------------------------------------------------------------------
xgnitesh's Profile: http://www.excelforum.com/member.php...o&userid=23874
View this thread: http://www.excelforum.com/showthread...hreadid=375150

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default new line character in cell


Could you post your code, and some examples maybe.

Mangesh


--
mangesh_yadav
------------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470
View this thread: http://www.excelforum.com/showthread...hreadid=375150

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default new line character in cell


Hi Mangesh

Thanks for your interest.
However the code I am using is already posted:
Cells(row, col).Value = GetAttribValue(objAttrib, strAttribName)
I am simply assigning a string variable to a cell value. You may
consider this

Cells(1, 1).Value = "Hello" + vbCrLf + "World"

Put the above line of code in a button click or sheet load method. You
will see that there is an extra character vbCr inserted before the
actual vbCrLf

Nitesh


--
xgnitesh
------------------------------------------------------------------------
xgnitesh's Profile: http://www.excelforum.com/member.php...o&userid=23874
View this thread: http://www.excelforum.com/showthread...hreadid=375150

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default new line character in cell


Use:
Cells(1, 1).Value = "Hello" + Chr(10) + "World"

Mangesh


--
mangesh_yadav
------------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470
View this thread: http://www.excelforum.com/showthread...hreadid=375150

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default new line character in cell


This is from the help:

vbCrLf Chr(13) + Chr(10) Carriage return–linefeed combination
vbCr Chr(13) Carriage return character
vbLf Chr(10) Linefeed character

Manges

--
mangesh_yada
-----------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...fo&userid=1047
View this thread: http://www.excelforum.com/showthread.php?threadid=37515



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default new line character in cell


Thanks Mangesh

This works fine:

Cells(1, 1).Value = "Hello" + Chr(10) + "World"

Regards
Nitesh


--
xgnitesh
------------------------------------------------------------------------
xgnitesh's Profile: http://www.excelforum.com/member.php...o&userid=23874
View this thread: http://www.excelforum.com/showthread...hreadid=375150

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default new line character in cell


Thanks for the feedback.

Mangesh


--
mangesh_yadav
------------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470
View this thread: http://www.excelforum.com/showthread...hreadid=375150

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default new line character in cell

I just replied to a similar topic above before I noticed this one.
This KB article gives a good overview of the ins and ons of VB's text
constants:
http://support.microsoft.com/?kbid=211774

Also, VbLf = chr(10) if you want to use a constant instead.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 - Formatting text in cell (character by character) TomC Excel Discussion (Misc queries) 0 January 29th 10 07:25 PM
Character for second line in a cell Gary Fitzgerald Excel Discussion (Misc queries) 2 December 8th 09 01:20 PM
Challenge - Excel Line Feed Character CHR(10) - How to Delete and keep the text formatting without going ro single line in a cell ? No Name Excel Worksheet Functions 7 October 7th 09 11:10 AM
How to put line feed in a cell using a character not Alt/Enter David Crowther Excel Discussion (Misc queries) 1 October 3rd 05 06:59 PM
New Line Character JohnBon Excel Programming 2 August 19th 04 04:05 PM


All times are GMT +1. The time now is 05:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"