Macro to change Userform Textbox Font attributes

J

JMay

I have 36 textboxes spread over 1 Userform - Multipage3

I'd like to change the:
1) font size to 12
2) Font Name to Arial
3) Bold
upon running 1 Macro

Is such a macro available? If so .. Where can I get it?
 
D

Dave Peterson

Are you doing all the textboxes?

Option Explicit
Private Sub UserForm_Initialize()
Dim ctrl As Control
For Each ctrl In Me.Controls
If TypeOf ctrl Is MSForms.TextBox Then
With ctrl.Object.Font
.Bold = True
.Name = "Arial"
.Size = 12
End With
End If
Next ctrl
End Sub

If you're not doing them all, you could skip based on name--or cycle through the
ones with nice names (TextBox01 thru TextBox36????).
 
J

JMay

Thanks Dave,

This routine is a one-time experience. Seems like it should be placed into
a standard module. To do so would it so something like:

Sub Foo
Dim ctrl as Control
With Userform1
YOUR CODE starting with For Each...
End With


Thanks Jim
 
D

Dave Peterson

I would think you'd want the textbox formatted that way each time you show the
userform--but that's just a guess.
 

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

Top