Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
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 |