Add blank line to userform's textbox caption?

EssKayKay

Active Member
Joined
Jan 5, 2003
Messages
448
Office Version
  1. 2007
Platform
  1. Windows
Hello,

Is it possible to add blank lines to a textbox "caption" that appears in an Excel userform?

Here is an example of what I have in mind. I’d like the text to display in the center of the red area (or further down). The name of the textbox is lblDue2.

1738116979604.png


Thanks for viewing,
SKK
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi EssKayKay,

I haven't found an easy way to center text verticaly, altought, I use the "Enter" character (chr(13)).

*text box doesn't have a caption attribute, only value attribute*

VBA Code:
myTextBox.value = chr(13) & chr(13) & "This text have 2 empty row above"

Bests regards,

Vincent
 
Upvote 0
To center exactly, it depends on the font type and the font size. The easiest thing is to add lines with vbCr, for example:

VBA Code:
Private Sub UserForm_Activate()

  With lblDue2
    .BackColor = &HFF&
    .MultiLine = True
    .Font.Bold = True
    .Font.Size = 12
    .TextAlign = fmTextAlignCenter
    .Value = vbCr & vbCr & vbCr & vbCr & "Escrow" & vbCr & "Distribution" & vbCr & "Due"
  End With
  
End Sub

1738118842363.png
 
Upvote 0
Thank you both for getting back so qauickly. However, I have not been able to get either of these solutions to do what I have in mind. I must stress, I am not a programmer so maybe this is beyond my pay-grade.

Colulombevin –
I’m not sure where I would put this code.

Donte –
I placed your code in a commend button (cmdTest2_Click) to see if it ran. I received a couple errors –
Compile Error – Method or data member not found
1738121563916.jpeg



1738121611775.jpeg


Here is my “test” routine where I placed your code:
Rich (BB code):
Private Sub cmdTest2_Click()
lblDUE2.Visible = True
Frame1.Visible = False

With lblDUE2
    .BackColor = &HFF&
    .MultiLine = True
    .Font.Bold = True
    .Font.Size = 12
    .TextAlign = fmTextAlignCenter
    .Value = vbCr & vbCr & vbCr & vbCr & "Escrow" & vbCr & "Distribution" & vbCr & "Due"
End With

End Sub

Here are the properties for my textbox (txtDUE2):
1738121754955.jpeg


Thanks again,
Steve K
 
Upvote 0
Hi Steve,

I see in your screen shot that you have a label, not a textbox which change a lot of thing.you could use what was said by Dante, but remove the line with .multiline = true and change the .value by .caption.

Otherwise, double click on your label lblDUE2 (or click in the properties panel in the cell at the right of caption) in your vba window, you should be able to change the text in the caption and add an "Enter", if not using shift+enter or alt+enter should do the trick.

Bests regards,

Vincent
 
Upvote 0
Solution
Hi Steve,

I see in your screen shot that you have a label, not a textbox which change a lot of thing.you could use what was said by Dante, but remove the line with .multiline = true and change the .value by .caption.

Otherwise, double click on your label lblDUE2 (or click in the properties panel in the cell at the right of caption) in your vba window, you should be able to change the text in the caption and add an "Enter", if not using shift+enter or alt+enter should do the trick.

Bests regards,

Vincent
WOW - thank you so very much. Sorry for using the wrong terminology (like I said, I’m not a programmer – not even much of a wannbe). I have a few other things I want to address regarding this but I’m most certainly moving in the right direction thanks to you both. You guys are amazing. . .

Side note: I did try the Alt+Enter. I pressed Alt+Enter in the Caption between Escrow (Alt+Enter) Distribution (Alt+Enter) Due. It did not work. I assume I was doing something wrong. I am running Excel 2007 which may be too old.

Again – much appreciated,
Steve K.
 
Upvote 0
Hi Steve,

No problem at all, we are here to help! In my case (Excel 365) it is shift+Enter that work to make a new line but I have to click twice (slowly otherwise it will create a method _Click() for the label) on the label in the constructor panel.

Do not hesitate to create new threads if you have any further questions,

Vincent
 
Upvote 0

Forum statistics

Threads
1,226,112
Messages
6,189,037
Members
453,520
Latest member
packrat68

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top