Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default centering text on textbox

I have a userform just to display some info. In the form I have a textbox
where I pull lots of info including some vbtab and vbcr.

is there a way to center some of the lines texts
I would like to put some titles in the middle but center in the textbox.

my program looks like this

Private Sub UserForm_Initialize()
Me.TextBox1 = _
"Model:" & vbTab & vbTab & vbTab & Range("o12").Value & vbCr _
& "Customer: " & vbTab & vbTab & Range("n26").Value & vbCr _
& "Qty:" & vbTab & vbTab & vbTab & Range("J26").Value & vbCr & vbCr _
& "Part Description: " & vbTab & Range("O17").Value & vbCr _
& "Original P/N: " & vbTab & vbTab & Range("O14").Value & vbCr _
& "Replacement P/N: " & vbTab & Range("O20").Value & vbCr _
& "ECR Requested: " & vbTab & Range("F12").Value & vbCr & vbCr _
& "Description: " & Range("A30").Value & vbCr & vbCr _
& "Prevention: " & Range("A38").Value & vbCr & vbCr
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default centering text on textbox


Use a listbox with multiple columns or add Microsoft Offsice Spreadsheet
object to you userform. There are a list of objects that you can add to
a userform by right click the toolbox and select additional controls.


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=170053

Microsoft Office Help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default centering text on textbox

Why don't you just put 9 Textboxes and 9 Labels on your userform? Then at
design time you can change the Caption property to "Model", "Customer", etc.
It would save you a lot of headches trying to center and format stuff. Hope
this helps! If so, let me know, click "YES" below.

Private Sub UserForm_Initialize()

Me.TextBox1 = Range("O12").Value
Me.TextBox2 = Range("N26").Value
Me.TextBox3 = Range("J26").Value
Me.TextBox4 = Range("O17").Value
Me.TextBox5 = Range("O14").Value
Me.TextBox6 = Range("O20").Value
Me.TextBox7 = Range("F12").Value
Me.TextBox8 = Range("A30").Value
Me.TextBox9 = Range("A38").Value

End Sub
--
Cheers,
Ryan


"Alberto Ast" wrote:

I have a userform just to display some info. In the form I have a textbox
where I pull lots of info including some vbtab and vbcr.

is there a way to center some of the lines texts
I would like to put some titles in the middle but center in the textbox.

my program looks like this

Private Sub UserForm_Initialize()
Me.TextBox1 = _
"Model:" & vbTab & vbTab & vbTab & Range("o12").Value & vbCr _
& "Customer: " & vbTab & vbTab & Range("n26").Value & vbCr _
& "Qty:" & vbTab & vbTab & vbTab & Range("J26").Value & vbCr & vbCr _
& "Part Description: " & vbTab & Range("O17").Value & vbCr _
& "Original P/N: " & vbTab & vbTab & Range("O14").Value & vbCr _
& "Replacement P/N: " & vbTab & Range("O20").Value & vbCr _
& "ECR Requested: " & vbTab & Range("F12").Value & vbCr & vbCr _
& "Description: " & Range("A30").Value & vbCr & vbCr _
& "Prevention: " & Range("A38").Value & vbCr & vbCr
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default centering text on textbox

A little more compact code...

Private Sub UserForm_Initialize()
Dim X As Long, Addresses() As String
Addresses = Split("O12 , N26, J26,O17,O14,O20, F12,A30,A38", ",")
For X = 1 To UBound(Addresses) + 1
Controls("TextBox" & X).Value = Range(Trim(Addresses(X - 1))).Value
Next
End Sub

This is also quite flexible in that if more TextBoxes are added or deleted, the only thing that needs to be changed is the list of addresses in the first argument to the Split function.

--
Rick (MVP - Excel)


"Ryan H" wrote in message ...
Why don't you just put 9 Textboxes and 9 Labels on your userform? Then at
design time you can change the Caption property to "Model", "Customer", etc.
It would save you a lot of headches trying to center and format stuff. Hope
this helps! If so, let me know, click "YES" below.

Private Sub UserForm_Initialize()

Me.TextBox1 = Range("O12").Value
Me.TextBox2 = Range("N26").Value
Me.TextBox3 = Range("J26").Value
Me.TextBox4 = Range("O17").Value
Me.TextBox5 = Range("O14").Value
Me.TextBox6 = Range("O20").Value
Me.TextBox7 = Range("F12").Value
Me.TextBox8 = Range("A30").Value
Me.TextBox9 = Range("A38").Value

End Sub
--
Cheers,
Ryan


"Alberto Ast" wrote:

I have a userform just to display some info. In the form I have a textbox
where I pull lots of info including some vbtab and vbcr.

is there a way to center some of the lines texts
I would like to put some titles in the middle but center in the textbox.

my program looks like this

Private Sub UserForm_Initialize()
Me.TextBox1 = _
"Model:" & vbTab & vbTab & vbTab & Range("o12").Value & vbCr _
& "Customer: " & vbTab & vbTab & Range("n26").Value & vbCr _
& "Qty:" & vbTab & vbTab & vbTab & Range("J26").Value & vbCr & vbCr _
& "Part Description: " & vbTab & Range("O17").Value & vbCr _
& "Original P/N: " & vbTab & vbTab & Range("O14").Value & vbCr _
& "Replacement P/N: " & vbTab & Range("O20").Value & vbCr _
& "ECR Requested: " & vbTab & Range("F12").Value & vbCr & vbCr _
& "Description: " & Range("A30").Value & vbCr & vbCr _
& "Prevention: " & Range("A38").Value & vbCr & vbCr
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default centering text on textbox

I meant to leave the spaces out of the list of addresses... they don't affect anything if left in (since I'm using the Trim function call) but they don't look all that nice.

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message ...
A little more compact code...

Private Sub UserForm_Initialize()
Dim X As Long, Addresses() As String
Addresses = Split("O12 , N26, J26,O17,O14,O20, F12,A30,A38", ",")
For X = 1 To UBound(Addresses) + 1
Controls("TextBox" & X).Value = Range(Trim(Addresses(X - 1))).Value
Next
End Sub

This is also quite flexible in that if more TextBoxes are added or deleted, the only thing that needs to be changed is the list of addresses in the first argument to the Split function.

--
Rick (MVP - Excel)


"Ryan H" wrote in message ...
Why don't you just put 9 Textboxes and 9 Labels on your userform? Then at
design time you can change the Caption property to "Model", "Customer", etc.
It would save you a lot of headches trying to center and format stuff. Hope
this helps! If so, let me know, click "YES" below.

Private Sub UserForm_Initialize()

Me.TextBox1 = Range("O12").Value
Me.TextBox2 = Range("N26").Value
Me.TextBox3 = Range("J26").Value
Me.TextBox4 = Range("O17").Value
Me.TextBox5 = Range("O14").Value
Me.TextBox6 = Range("O20").Value
Me.TextBox7 = Range("F12").Value
Me.TextBox8 = Range("A30").Value
Me.TextBox9 = Range("A38").Value

End Sub
--
Cheers,
Ryan


"Alberto Ast" wrote:

I have a userform just to display some info. In the form I have a textbox
where I pull lots of info including some vbtab and vbcr.

is there a way to center some of the lines texts
I would like to put some titles in the middle but center in the textbox.

my program looks like this

Private Sub UserForm_Initialize()
Me.TextBox1 = _
"Model:" & vbTab & vbTab & vbTab & Range("o12").Value & vbCr _
& "Customer: " & vbTab & vbTab & Range("n26").Value & vbCr _
& "Qty:" & vbTab & vbTab & vbTab & Range("J26").Value & vbCr & vbCr _
& "Part Description: " & vbTab & Range("O17").Value & vbCr _
& "Original P/N: " & vbTab & vbTab & Range("O14").Value & vbCr _
& "Replacement P/N: " & vbTab & Range("O20").Value & vbCr _
& "ECR Requested: " & vbTab & Range("F12").Value & vbCr & vbCr _
& "Description: " & Range("A30").Value & vbCr & vbCr _
& "Prevention: " & Range("A38").Value & vbCr & vbCr
End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default centering text on textbox

Thanks for all the inputs...

I do not think I can use several textbpxes or labels because the lenght of
each item can vary a lot so I will need to have space enough for each item
rather than just one are with all data... it will not look good.

I will try joel options, did acess such option and there are too many pcs of
information... do not think it will work but I will try... most chances is it
should work because my experience is very low on this so I should be wrong.

"joel" wrote:


Use a listbox with multiple columns or add Microsoft Offsice Spreadsheet
object to you userform. There are a list of objects that you can add to
a userform by right click the toolbox and select additional controls.


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=170053

Microsoft Office Help

.

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
Centering and warping text Nils Titley Excel Programming 6 March 20th 08 10:11 PM
text centering AlanW Excel Programming 1 September 1st 07 08:22 AM
Centering Text Not Working caldog Excel Programming 5 December 21st 05 01:42 AM
Centering the text in a message box Rob_T Excel Programming 2 October 10th 04 01:12 AM
Centering the text in a message box Rob_T Excel Programming 4 October 8th 04 10:02 AM


All times are GMT +1. The time now is 02:56 PM.

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"