Приложение 1. Листинг модуля Excel Private Sub ComboBox1_Change() End Sub Private Sub CommandButton1_Click() If (ComboBox1.Text = "2") Then UserForm2.TextBox3.Visible = False UserForm2.TextBox4.Visible = False UserForm2.TextBox7.Visible = False UserForm2.TextBox8.Visible = False UserForm2.TextBox9.Visible = False UserForm2.TextBox10.Visible = False UserForm2.TextBox11.Visible = False UserForm2.TextBox12.Visible = False UserForm2.TextBox13.Visible = False UserForm2.TextBox14.Visible = False UserForm2.TextBox15.Visible = False UserForm2.TextBox16.Visible = False UserForm2.Label3.Visible = False UserForm2.Label4.Visible = False UserForm2.Label7.Visible = False UserForm2.Label8.Visible = False End If If (ComboBox1.Text = "3") Then UserForm2.TextBox13.Visible = False UserForm2.TextBox14.Visible = False UserForm2.TextBox15.Visible = False UserForm2.TextBox16.Visible = False UserForm2.TextBox4.Visible = False UserForm2.TextBox8.Visible = False UserForm2.TextBox12.Visible = False UserForm2.TextBox16.Visible = False UserForm2.Label4.Visible = False UserForm2.Label8.Visible = False End If UserForm2.Show End Sub Private Sub UserForm_Click() End Sub Private Sub UserForm_Initialize() ComboBox1.Text = "2" ComboBox1.AddItem "2" ComboBox1.AddItem "3" ComboBox1.AddItem "4" End Sub Private Sub CommandButton1_Click() If (UserForm1.ComboBox1.Text = "2") Then If (TextBox1.Text = "") Or (TextBox2.Text = "") Or (TextBox5.Text = "") Or (TextBox6.Text = "") Then MsgBox "Заполните все поля" If (UserForm1.ComboBox1.Text = "3") Then If (TextBox1.Text = "") Or (TextBox2.Text = "") Or (TextBox3.Text = "") Or (TextBox5.Text = "") Or (TextBox6.Text = "") Or (TextBox7.Text = "") Or (TextBox9.Text = "") Or (TextBox10.Text = "") Or (TextBox11.Text = "") Then MsgBox "Заполните все поля" End If If (UserForm1.ComboBox1.Text = "4") Then If (TextBox1.Text = "") Or (TextBox2.Text = "") Or (TextBox3.Text = "") Or (TextBox4.Text = "") Or (TextBox5.Text = "") Or (TextBox6.Text = "") Or (TextBox7.Text = "") Or (TextBox8.Text = "") Or (TextBox9.Text = "") Or (TextBox10.Text = "") Or (TextBox11.Text = "") Or (TextBox12.Text = "") Or (TextBox13.Text = "") Or (TextBox14.Text = "") Or (TextBox15.Text = "") Or (TextBox16.Text = "") Then MsgBox "Заполните все поля" End If Worksheets("ИсходныеДанные").Range("A1") = TextBox1.Text Worksheets("ИсходныеДанные").Range("B1") = TextBox2.Text Worksheets("ИсходныеДанные").Range("C1") = TextBox3.Text Worksheets("ИсходныеДанные").Range("D1") = TextBox4.Text Worksheets("ИсходныеДанные").Range("A2") = TextBox5.Text Worksheets("ИсходныеДанные").Range("B2") = TextBox6.Text Worksheets("ИсходныеДанные").Range("C2") = TextBox7.Text Worksheets("ИсходныеДанные").Range("D2") = TextBox8.Text Worksheets("ИсходныеДанные").Range("A3") = TextBox9.Text Worksheets("ИсходныеДанные").Range("B3") = TextBox10.Text Worksheets("ИсходныеДанные").Range("C3") = TextBox11.Text Worksheets("ИсходныеДанные").Range("D3") = TextBox12.Text Worksheets("ИсходныеДанные").Range("A4") = TextBox13.Text Worksheets("ИсходныеДанные").Range("B4") = TextBox14.Text Worksheets("ИсходныеДанные").Range("C4") = TextBox15.Text Worksheets("ИсходныеДанные").Range("D4") = TextBox16.Text UserForm2.TextBox1.Text = Clear UserForm2.TextBox2.Text = Clear UserForm2.TextBox3.Text = Clear UserForm2.TextBox4.Text = Clear UserForm2.TextBox5.Text = Clear UserForm2.TextBox6.Text = Clear UserForm2.TextBox7.Text = Clear UserForm2.TextBox8.Text = Clear UserForm2.TextBox9.Text = Clear UserForm2.TextBox10.Text = Clear UserForm2.TextBox11.Text = Clear UserForm2.TextBox12.Text = Clear UserForm2.TextBox13.Text = Clear UserForm2.TextBox14.Text = Clear UserForm2.TextBox15.Text = Clear UserForm2.TextBox16.Text = Clear End Sub Private Function ValidateNumeric(strText As String) _ As Boolean ValidateNumeric = CBool(strText = "" _ Or strText = "-." _ Or strText = "." _ Or IsNumeric(strText)) End Function Private Sub TextBox1_Change() If Not ValidateNumeric(TextBox1.Text) Then TextBox1.Text = "" End If End Sub Private Sub TextBox2_Change() If Not ValidateNumeric(TextBox2.Text) Then TextBox2.Text = "" End If End Sub Private Sub TextBox3_Change() If Not ValidateNumeric(TextBox3.Text) Then TextBox3.Text = "" End If End Sub Private Sub TextBox4_Change() If Not ValidateNumeric(TextBox4.Text) Then TextBox4.Text = "" End If End Sub Private Sub TextBox5_Change() If Not ValidateNumeric(TextBox5.Text) Then TextBox5.Text = "" End If End Sub Private Sub TextBox6_Change() If Not ValidateNumeric(TextBox6.Text) Then TextBox6.Text = "" End If End Sub Private Sub TextBox7_Change() If Not ValidateNumeric(TextBox7.Text) Then TextBox7.Text = "" End If End Sub Private Sub TextBox8_Change() If Not ValidateNumeric(TextBox8.Text) Then TextBox8.Text = "" End If End Sub Private Sub TextBox9_Change() If Not ValidateNumeric(TextBox9.Text) Then TextBox9.Text = "" End If End Sub Private Sub TextBox10_Change() If Not ValidateNumeric(TextBox10.Text) Then TextBox10.Text = "" End If End Sub Private Sub TextBox11_Change() If Not ValidateNumeric(TextBox11.Text) Then TextBox11.Text = "" End If End Sub Private Sub TextBox12_Change() If Not ValidateNumeric(TextBox12.Text) Then TextBox12.Text = "" End If End Sub Private Sub TextBox13_Change() If Not ValidateNumeric(TextBox13.Text) Then TextBox13.Text = "" End If End Sub Private Sub TextBox14_Change() If Not ValidateNumeric(TextBox14.Text) Then TextBox14.Text = "" End If End Sub Private Sub TextBox15_Change() If Not ValidateNumeric(TextBox15.Text) Then TextBox15.Text = "" End If End Sub Private Sub TextBox16_Change() If Not ValidateNumeric(TextBox16.Text) Then TextBox16.Text = "" End If End Sub Размещено на Allbest.ru |