Описание функционирование формы (события) с приведением листинга соответствующих процедур

Option Explicit

Dim rez As String

Private Sub CheckBox1_Click()

If CheckBox1.Value = False Then

t1.Enabled = False

Else

t1.Enabled = True

End If

End Sub

Private Sub CheckBox2_Click()

If CheckBox2.Value = False Then

t2.Enabled = False

Else

t2.Enabled = True

End If

End Sub

Private Sub CheckBox3_Click()

If CheckBox3.Value = False Then

t3.Enabled = False

Else

t3.Enabled = True

End If

End Sub

Private Sub CheckBox4_Click()

If CheckBox4.Value = False Then

t4.Enabled = False

Else

t4.Enabled = True

End If

End Sub

Private Sub CheckBox5_Click()

If CheckBox5.Value = False Then

t5.Enabled = False

Else

t5.Enabled = True

End If

End Sub

Private Sub CheckBox6_Click()

If CheckBox6.Value = False Then

t6.Enabled = False

Else

t6.Enabled = True

End If

End Sub

Private Sub UserForm_Initialize()

CheckBox1.Value = True

CheckBox2.Value = True

CheckBox3.Value = True

CheckBox4.Value = True

CheckBox5.Value = True

CheckBox6.Value = True

End Sub

Private Sub CommandButton1_Click()

Const a = "I43:J43", d = "I44:J44 ", c = "I45:J45", e = "I46:J46", f = "I47:J47", k = "I48:J48"

rez = Empty

If Charts.Count <> 0 Then Charts.Delete

If CheckBox1.Value = True Then rez = rez & a

If CheckBox2.Value = True Then

If rez <> Empty Then

rez = rez & "," & d

Else

rez = rez & d

End If

End If

If CheckBox3.Value = True Then

If rez <> Empty Then

rez = rez & "," & c

Else

rez = rez & c

End If

End If

If CheckBox4.Value = True Then

If rez <> Empty Then

rez = rez & "," & e

Else

rez = rez & e

End If

End If

If CheckBox5.Value = True Then

If rez <> Empty Then

rez = rez & "," & f

Else

rez = rez & f

End If

End If

If CheckBox6.Value = True Then

If rez <> Empty Then

rez = rez & "," & k

Else

rez = rez & k

End If

End If

'проверка строки

If rez = Empty Then

MsgBox "Выберите данные"

Exit Sub

End If

If OptionButton1.Value = True Then

Charts.Add

ActiveChart.ChartType = xl3DColumnClustered

ActiveChart.SetSourceData Source:=Sheets("Лист1").Range(rez), PlotBy:= _

xlColumns

ActiveChart.Location Where:=xlLocationAsNewSheet

With ActiveChart

.HasTitle = True

.ChartTitle.Characters.Text = "Диаграмма основных затрат по смете"

.Axes(xlCategory).HasTitle = False

End With

ActiveChart.HasLegend = True

ActiveChart.Legend.Select

Selection.Position = xlRight

End If

If OptionButton2.Value = True Then

Charts.Add

ActiveChart.ChartType = xlPie

ActiveChart.SetSourceData Source:=Sheets("Лист1").Range(rez), PlotBy:= _

xlColumns

ActiveChart.Location Where:=xlLocationAsNewSheet

With ActiveChart

.HasTitle = True

.ChartTitle.Characters.Text = "Диаграмма основных затрат по смете"

End With

ActiveChart.HasLegend = True

ActiveChart.Legend.Select

Selection.Position = xlRight

End If

If OptionButton3.Value = True Then

Charts.Add

ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _

"ЧБ круговая"

ActiveChart.SetSourceData Source:=Sheets("Лист1").Range(rez), PlotBy:= _

xlColumns

ActiveChart.Location Where:=xlLocationAsNewSheet

With ActiveChart

.HasTitle = True

.ChartTitle.Characters.Text = "Диаграмма основных затрат по смете"

End With

ActiveChart.HasLegend = True

ActiveChart.Legend.Select

Selection.Position = xlRight

End If

End Sub