Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Centering and warping text | Excel Programming | |||
text centering | Excel Programming | |||
Centering Text Not Working | Excel Programming | |||
Centering the text in a message box | Excel Programming | |||
Centering the text in a message box | Excel Programming |