How in VBA set Font Size for a checkbox?

jzurbo77

New Member
Joined
Nov 9, 2007
Messages
4
I have some code that creates two groups of checkboxes on a radar chart (we call them "for tests" and "for series").
Can not figure out how to setup font.size for it. Tried to stick it in few spots - no luck.
Attached is a sample couple of checkboxes created by this code (for tests)

Any suggestions will be appreciated.


Public Sub AddControl(chartStar As Chart)
Dim i As Long, j As Long
Dim lcb As Single, tcb As Single, wcb As Single, hcb As Single, rng As Range, sha As Shape, cbOnOff As Boolean

If NoData Then Exit Sub
If chartStar Is Nothing Then Exit Sub

With chartStar
' CheckBox for tests
tcb = 4
lcb = 4
wcb = rngSource.Columns(0).Width + 12 ' 30
hcb = (.ChartArea.Height - 8) / cntDataSeries ' 12
If hcb > 16 Then hcb = 16
If hcb < 12 Then hcb = 12

For i = 1 To cntDataTest
Set sha = .Shapes.AddFormControl(xlCheckBox, lcb, tcb, wcb, hcb)
With sha
.TextFrame.Characters.Text = rngSource(i, ncCheckBoxName - ncTestName).Text
.Name = "cbT" & CStr(i)
cbOnOff = (rngSource(i, ncChecked - ncTestName) <> "")
If cbOnOff Then
.ControlFormat.Value = xlOn
Else
.ControlFormat.Value = xlOff
rngSource(i, 1).EntireRow.Hidden = True
chartBar(i).Visible = xlSheetHidden
End If
.OnAction = "cbClick"
End With

tcb = tcb + hcb
If tcb > .ChartArea.Height - hcb - 4 Then
lcb = lcb + wcb + 1
tcb = tcb - hcb * (cntDataTest - i)
End If
Next

' CheckBox for series
tcb = 4
lcb = .Legend.Left
wcb = .Legend.Width
hcb = 16
For i = cntGradientPoint + 1 To cntGradientPoint + cntDataSeries
Set sha = .Shapes.AddFormControl(xlCheckBox, lcb, tcb, wcb, hcb)
With sha
.TextFrame.Characters.Text = rngSource(0, i - cntGradientPoint).Text
.Name = "cbS" & CStr(i - cntGradientPoint)
.ControlFormat.Value = xlOn
.OnAction = "cbClick"
tcb = tcb + hcb
End With
Next

End With
End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,295
Office Version
  1. 365
Platform
  1. Windows
You can't change the font size of a Forms checkbox either manually or via code.:)
 

beerskel

New Member
Joined
May 28, 2007
Messages
5
here's my cheat...

clear any text from the check box and place a rectangle (object) with formated text next to the check. then select the check box and 'bring to front'.
 

Watch MrExcel Video

Forum statistics

Threads
1,132,671
Messages
5,654,659
Members
418,146
Latest member
Shnn028

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top