Private Sub CommandButton1_Click() ' pulsante inserisci
Application.ScreenUpdating = False
If ComboBox1 = "" Then
Label1.ForeColor = RGB(255, 0, 0)
MsgBox ("Attenzione! Devi inserire un titolo Sig.re oppure Sig.ra oppure Sig.na."), vbExclamation, "Excel e VBA"
ComboBox1.SetFocus
Exit Sub
End If
If TextBox2.Text = "" Then
Label2.ForeColor = RGB(255, 0, 0)
MsgBox "Attenzione! Devi inserire il Nome.", vbExclamation, "Excel e VBA"
TextBox2.SetFocus
Exit Sub
End If
If TextBox3.Text = "" Then
Label3.ForeColor = RGB(255, 0, 0)
MsgBox "Attenzione! Devi inserire il Cognome.", vbExclamtion, "Excel e VBA"
TextBox3.SetFocus
Exit Sub
End If
If TextBox4.Text = "" Then
Label4.ForeColor = RGB(255, 0, 0)
MsgBox "Attenzione! Devi inserire l'indirizzo.", vbExclamtion, "Excel e VBA"
TextBox4.SetFocus
Exit Sub
End If
If TextBox9.Text = "" Then
Label10.ForeColor = RGB(255, 0, 0)
MsgBox "Attenzione! Devi inserire il CAP.", vbExclamtion, "Excel e VBA"
TextBox9.SetFocus
Exit Sub
End If
If ComboBox2 = "" Then
Label8.ForeColor = RGB(255, 0, 0)
MsgBox "Attenzione! Devi inserire la città.", vbExclamtion, "Excel e VBA"
ComboBox2.SetFocus
Exit Sub
End If
If TextBox8.Text = "" Then
Label9.ForeColor = RGB(255, 0, 0)
MsgBox "Attenzione! Devi inserire il numero di telefono dell'ufficio.", vbExclamation, "Excel e VBA"
TextBox8.SetFocus
Exit Sub
End If
If TextBox10.Text = "" Then
Label11.ForeColor = RGB(255, 0, 0)
MsgBox "Attenzione! Devi inserire il numero di telefono di casa.", vbExclamation, "Excel e VBA"
TextBox10.SetFocus
Exit Sub
End If
If TextBox6.Text = "" Then
Label6.ForeColor = RGB(255, 0, 0)
MsgBox "Attenzione! Devi inserire il numero di cellulare.", vbExclamation, "Excel e VBA"
TextBox6.SetFocus
Exit Sub
End If
If TextBox7.Text = "" Then
Label7.ForeColor = RGB(255, 0, 0)
MsgBox "Attenzione! Devi inserire l'E-mail.", vbExclamation, "Excel e VBA"
TextBox7.SetFocus
Exit Sub
End If
Range("A65535").End(xlUp).Offset(1, 0).Select
ActiveCell.Value = ComboBox1
ActiveCell.Offset(0, 1).Value = TextBox2
ActiveCell.Offset(0, 2).Value = TextBox3
ActiveCell.Offset(0, 3).Value = TextBox4
ActiveCell.Offset(0, 4).Value = TextBox9
ActiveCell.Offset(0, 5).Value = ComboBox2
ActiveCell.Offset(0, 6).Value = TextBox8
ActiveCell.Offset(0, 7).Value = TextBox10
ActiveCell.Offset(0, 8).Value = TextBox6
ActiveCell.Offset(0, 9).Value = TextBox7
End Sub |