My question is; is there a way of adding the font pick list and size controls to a form - like the one you see when you call up the "format cells" box by right clicking on a cell? And how do you capture the selections?
The easiest way to implement this is to use Excel's built-in dialogs. Here is a simple procedure that displays the standard Font dialog you would see when selecting Cells|Format:
Code:
Sub DisplayFontDialog()
Dim dlgResult As Variant
dlgResult = Application.Dialogs(xlDialogFontProperties).Show
End Sub
When this dialog is invoked, it references the current selection. Either have your code select the appropriate cells prior to calling or let the user make the selection. To do that from a modal Userform, use a RefEdit control then set the selection on exit. Example (code in the Userform's module):
Code:
Private Sub RefEdit1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ActiveSheet.Range(RefEdit1.Text).Select
End Sub
Private Sub CommandButton1_Click()
FontPickList
End Sub
I used a separate CommandButton to run the Font dialog display procedure.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.