ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Use Macro to Format UserForm Object (https://www.excelbanter.com/excel-programming/438120-use-macro-format-userform-object.html)

RussellT

Use Macro to Format UserForm Object
 
I have a UserForm with dozens of textboxes on it. I periodically need to
change the formatting of the textboxes and I been trying to write a macro to
do it to no avail. Here' what I thought would work but it doesn't. HELP
PLEASE. THANKS

Sub ChangeFonts_Click()
Dim Boxes As Long
With editForm
For Boxes = 1 To 78
("TextBox" & Boxes).font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
Next
End With
End Sub

Rick Rothstein

Use Macro to Format UserForm Object
 
Try this code instead and see if it does what you want...

Sub ChangeFonts_Click()
Dim C As Control
For Each C In editForm.Controls
If TypeOf C Is msforms.TextBox Then
With C.Font
.Name = "Arial"
.Size = 10
.Bold = True
End With
End If
Next
End Sub

--
Rick (MVP - Excel)


"RussellT" wrote in message
...
I have a UserForm with dozens of textboxes on it. I periodically need to
change the formatting of the textboxes and I been trying to write a macro
to
do it to no avail. Here' what I thought would work but it doesn't. HELP
PLEASE. THANKS

Sub ChangeFonts_Click()
Dim Boxes As Long
With editForm
For Boxes = 1 To 78
("TextBox" & Boxes).font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
Next
End With
End Sub




All times are GMT +1. The time now is 01:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com