vbCr

  • Thread starter Thread starter jimmy
  • Start date Start date
J

jimmy

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
 
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
 
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.caption = "first" & vbcr &
"second"

with the cursor at the end of the line hit Enter

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top