#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default vbCr

Hi,

I tried to use vbCr in the caption property of commandbutton is work but it
doesn't work in putting contents in a cell, what is the code to get the
result like pressing "Alt + Enter" in a cell?

Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,365
Default vbCr

Try something like this for cells. I just picked H1 because it was handy:

Range("H1").NumberFormat = "@" ' set to text format
Range("H1") = "Hello" & vbLf & "goodbye." 'use vbLf vs vbCr or vbCrLf
Range("H1").WrapText = True ' hides the little square box


"jimmy" wrote:

Hi,

I tried to use vbCr in the caption property of commandbutton is work but it
doesn't work in putting contents in a cell, what is the code to get the
result like pressing "Alt + Enter" in a cell?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default vbCr

If it's a Commandbutton on a userform1, at runtime -

CommandButton1.Caption = "First Line" & vbCr & "Second line"

To set at design time probably simplest to copy the two line text from a
cell into the caption property.

If is a commandbutton on a worksheet, in the immediate window (ctrl-g) -

ActiveSheet.oleobjects("CommandButton1").object.ca ption = "first" & vbcr &
"second"

with the cursor at the end of the line hit Enter

Regards,
Peter T


"jimmy" wrote in message ...
Hi,

I tried to use vbCr in the caption property of commandbutton is work but

it
doesn't work in putting contents in a cell, what is the code to get the
result like pressing "Alt + Enter" in a cell?

Thanks




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
if AddIn_1 isRunning vbcr application.enableEvents=False vbcr end if: how to do this?? Matthew Dodds Excel Programming 1 April 17th 07 08:45 PM
Having trouble with "vbcr" terrysoper1973 Excel Programming 3 January 6th 06 03:56 PM
vblf and vbcr one last question terrysoper1973[_2_] Excel Programming 2 January 5th 06 10:49 PM
Supressing CHR13 or vbCr write in text file Edwin Niemoller[_2_] Excel Programming 0 March 9th 05 08:38 PM


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

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

About Us

"It's about Microsoft Excel"