hello everyone..
ive a small yet annoying problem that ive been trying to figure out for the last 5 or so days..
what i have is a userform that allows you to change the font( fontname,colour,bold,underline etc)
i have everythign working apart from the fontnames. these ar populated in the combobox( lists names of text, only a select 5 "arial", Times New", "garamaond", "Comic Sans")
all these functions change the properties of the text in a Cell, not a textbox. the problem is getting the font to change when it is selected from the combobox. but only applied when the "Ok" button is clicked
heres the code so far:
cmdok is the ok button( after clicked the target cell is updated)
cbofont is the combobox
txtimput= is the text imput box the code, uses the text in the textbox then displays it in a cell
Option Explicit
Private Sub cmdok_Click()
Dim mytext As String
mytext = txtinput.Text
Range(rfecell.Text).Activate
ActiveCell.Formula = mytext
If optred.Value = True Then
ActiveCell.Font.Color = vbRed
ElseIf optgreen.Value = True Then
ActiveCell.Font.Color = vbGreen
ElseIf optblue.Value = True Then
ActiveCell.Font.Color = vbBlue
End If
If chkund = True Then
ActiveCell.Font.Underline = xlUnderlineStyleSingle
Else
ActiveCell.Font.Underline = False
End If
If chkbold = True Then
ActiveCell.Font.Bold = True
Else
ActiveCell.Font.Bold = False
End If
End Sub
Sub Userform_Initialize()
optred.Value = True
chkbold.Value = True
With cbofont
.AddItem "Times New Roman"
.AddItem "Comic Sans MS"
.AddItem "Garamond"
.AddItem "Arial"
.ListIndex = 0
End With
End Sub
Private Sub cbofont_Click()
Select Case cbofont
Case Is = "Times New Roman"
ActiveCell.Font.Name = "Times New Roman"
End Select
End Sub
Private Sub cmdquit_Click()
Unload Me
End Sub
thank you
ive a small yet annoying problem that ive been trying to figure out for the last 5 or so days..
what i have is a userform that allows you to change the font( fontname,colour,bold,underline etc)
i have everythign working apart from the fontnames. these ar populated in the combobox( lists names of text, only a select 5 "arial", Times New", "garamaond", "Comic Sans")
all these functions change the properties of the text in a Cell, not a textbox. the problem is getting the font to change when it is selected from the combobox. but only applied when the "Ok" button is clicked
heres the code so far:
cmdok is the ok button( after clicked the target cell is updated)
cbofont is the combobox
txtimput= is the text imput box the code, uses the text in the textbox then displays it in a cell
Option Explicit
Private Sub cmdok_Click()
Dim mytext As String
mytext = txtinput.Text
Range(rfecell.Text).Activate
ActiveCell.Formula = mytext
If optred.Value = True Then
ActiveCell.Font.Color = vbRed
ElseIf optgreen.Value = True Then
ActiveCell.Font.Color = vbGreen
ElseIf optblue.Value = True Then
ActiveCell.Font.Color = vbBlue
End If
If chkund = True Then
ActiveCell.Font.Underline = xlUnderlineStyleSingle
Else
ActiveCell.Font.Underline = False
End If
If chkbold = True Then
ActiveCell.Font.Bold = True
Else
ActiveCell.Font.Bold = False
End If
End Sub
Sub Userform_Initialize()
optred.Value = True
chkbold.Value = True
With cbofont
.AddItem "Times New Roman"
.AddItem "Comic Sans MS"
.AddItem "Garamond"
.AddItem "Arial"
.ListIndex = 0
End With
End Sub
Private Sub cbofont_Click()
Select Case cbofont
Case Is = "Times New Roman"
ActiveCell.Font.Name = "Times New Roman"
End Select
End Sub
Private Sub cmdquit_Click()
Unload Me
End Sub
thank you
Last edited: