Private Sub BtIncluir_Click()
Dim msgDuplicado As String
If Not Worksheets("cadastro").Range("A7:A40").Find(ComboBox1.Text) Is Nothing Then
msgDuplicado = MsgBox("Este código já está cadastrado. Continua?", vbInformation + vbYesNo, "Aviso!")
Select Case msgDuplicado
Case vbNo
Exit Sub
End Select
End If
If Not Worksheets("cadastro").Range("A7:A40").Find(ComboBox1.Text) Is Nothing Then
msgDuplicado = MsgBox("Este código já está cadastrado. Continua?", vbInformation + vbYesNo, "Aviso!")
Select Case msgDuplicado
Case vbYes
End Select
End If
Set c = Sheet1.Range("A65536").End(xlUp).Offset(1, 0)
Application.ScreenUpdating = False
c.Value = Me.ComboBox1.Text
c.Offset(0, 1).Value = Me.ComboBox2.Value
c.Offset(0, 2).Value = Me.ComboBox3.Value
c.Offset(0, 3).Value = Me.ComboBox4.Value
c.Offset(0, 4).Value = Me.ComboBox5.Value
c.Offset(0, 5).Value = Me.TextBox6.Value
c.Offset(0, 6).Value = Me.TextBox7.Value
c.Offset(0, 7).Value = Me.TextBox8.Value
c.Offset(0, 8).Value = Me.TextBox9.Value
c.Offset(0, 9).Value = Me.TextBox10.Value
c.Offset(0, 10).Value = Me.ComboBox1.Value
c.Offset(0, 11).Value = Me.CboTipo.Value
With Me
.ComboBox1.Text = vbNullString
.ComboBox2.Value = vbNullString
.ComboBox3.Value = vbNullString
.ComboBox4.Value = vbNullString
.ComboBox5.Value = vbNullString
.TextBox6.Value = vbNullString
.TextBox7.Value = vbNullString
.TextBox8.Value = vbNullString
.TextBox9.Value = vbNullString
.TextBox10.Value = vbNullString
End With
Application.ScreenUpdating = True
ActiveWorkbook.Worksheets("Cadastro").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Cadastro").Sort.SortFields.Add Key:=Range("A7:A40" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Cadastro").Sort
.SetRange Range("A7:L40")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
Range("A7").Select
End With
With PG
If PG.Value >= 1 And PG.Value <= 3 Then
Worksheets("Receita").Range("E14").Value = "28%"
ComboBox4.Value = "0%"
ElseIf PG.Value >= 4 And PG.Value <= 6 Then
Worksheets("Receita").Range("E14").Value = "25%"
ComboBox4.Value = "0%"
ElseIf PG.Value = 7 Then
Worksheets("Receita").Range("E14").Value = "22%"
ComboBox4.Value = "0%"
ElseIf PG.Value >= 8 And PG.Value <= 10 Then
Worksheets("Receita").Range("E14").Value = "19%"
ComboBox4.Value = "0%"
ElseIf PG.Value >= 11 And PG.Value <= 14 Then
Worksheets("Receita").Range("E14").Value = "16%"
ComboBox4.Value = "0%"
ElseIf PG.Value >= 15 And PG.Value <= 18 Then
Worksheets("Receita").Range("E14").Value = "13%"
ComboBox4.Value = "0%"
ElseIf PG.Value >= 20 And PG.Value <= 22 Then
Worksheets("Receita").Range("E14").Value = "13%"
ComboBox4.Value = "0%"
ElseIf PG.Value = 19 Or PG.Value = 23 Then
Worksheets("Receita").Range("E14").Value = "0%"
ComboBox4.Value = "0%"
End If
End With
End Sub