rafaelsb21
30-08-2017 14:07:18
Bom dia!
preciso de um help: preciso automatizar um processo de cálculo de pontos de função. Tenho um campo em que digito um valor chamado: Tamanho do projeto e outro campo chamado Complexidade, que pode ser Baixa ou Média. Eu preciso colocar o valor, conforme digitado nas células B3(tamanho do projeto) e B4(complexidade).
Criei no VBA essas rotinas: calcula_dias(), calcula_dias_2() e Worksheet_Change(todas abaixo). A minha dúvida é como acionar a rotina Worksheet_Change quando eu alterar a célula B3 e B4 para calcular o resultado e colocar na B7.
Private Sub calcula_dias()
If Plan6.Range("B3").Value <= 10 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 9
End If
If Plan6.Range("B3").Value <= 10 And Plan6.Range("B3").Value = "Media" Then
Plan6.Range("B7").Value = 15
End If
If Plan6.Range("B3").Value >= 11 And Plan6.Range("B3").Value <= 20 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 18
End If
If Plan6.Range("B3").Value >= 11 And Plan6.Range("B3").Value <= 20 And Plan6.Range("B4").Value = "Media" Then
Plan6.Range("B7").Value = 30
End If
If Plan6.Range("B3").Value >= 21 And Plan6.Range("B3").Value <= 30 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 27
End If
If Plan6.Range("B3").Value >= 21 And Plan6.Range("B3").Value <= 30 And Plan6.Range("B4").Value = "Media" Then
Plan6.Range("B7").Value = 45
End If
If Plan6.Range("B3").Value >= 31 And Plan6.Range("B3").Value <= 40 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 36
End If
If Plan6.Range("B3").Value >= 31 And Plan6.Range("B3").Value <= 40 And Plan6.Range("B4").Value = "Media" Then
Plan6.Range("B7").Value = 60
End If
If Plan6.Range("B3").Value >= 41 And Plan6.Range("B3").Value <= 50 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 45
End If
If Plan6.Range("B3").Value >= 41 And Plan6.Range("B3").Value <= 50 And Plan6.Range("B4").Value = "Media" Then
Plan6.Range("B7").Value = 75
End If
If Plan6.Range("B3").Value >= 51 And Plan6.Range("B3").Value <= 60 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 54
End If
If Plan6.Range("B3").Value >= 51 And Plan6.Range("B3").Value <= 60 And Plan6.Range("B4").Value = "Media" Then
Plan6.Range("B7").Value = 90
End If
If Plan6.Range("B3").Value >= 61 And Plan6.Range("B3").Value <= 70 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 63
End If
If Plan6.Range("B3").Value >= 61 And Plan6.Range("B3").Value <= 70 And Plan6.Range("B4").Value = "Media" Then
Plan6.Range("B7").Value = 105
End If
If Plan6.Range("B3").Value >= 71 And Plan6.Range("B3").Value <= 85 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 70
End If
If Plan6.Range("B3").Value >= 71 And Plan6.Range("B3").Value <= 85 And Plan6.Range("B4").Value = "Media" Then
Plan6.Range("B7").Value = 110
End If
If Plan6.Range("B3").Value >= 86 And Plan6.Range("B3").Value <= 99 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 99
End If
If Plan6.Range("B3").Value >= 86 And Plan6.Range("B3").Value <= 99 And Plan6.Range("B4").Value = "Media" Then
Plan6.Range("B7").Value = 110
End If
End Sub
Private Sub calcula_dias_2()
If Plan6.Range("G3").Value <= 10 And Plan6.Range("G4").Value = "Sistema Comum (WEB ou Cliente Servidor)" Then
Plan6.Range("G7").Value = Plan6.Range("G3").Value * 0.34
G8 = G7 * 22
End If
If Plan6.Range("G3").Value <= 10 And Plan6.Range("G4").Value <> "Sistema Comum (WEB ou Cliente Servidor)" Then
Plan6.Range("G7").Value = Plan6.Range("G3").Value * 0.37
Plan6.Range("G8").Value = Plan6.Range("G7").Value * 22
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$3" And Target.Address = "$B$4" Then
Call calcula_dias
Exit Sub
End If
End Sub
Aguardo,
Rafael
preciso de um help: preciso automatizar um processo de cálculo de pontos de função. Tenho um campo em que digito um valor chamado: Tamanho do projeto e outro campo chamado Complexidade, que pode ser Baixa ou Média. Eu preciso colocar o valor, conforme digitado nas células B3(tamanho do projeto) e B4(complexidade).
Criei no VBA essas rotinas: calcula_dias(), calcula_dias_2() e Worksheet_Change(todas abaixo). A minha dúvida é como acionar a rotina Worksheet_Change quando eu alterar a célula B3 e B4 para calcular o resultado e colocar na B7.
Private Sub calcula_dias()
If Plan6.Range("B3").Value <= 10 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 9
End If
If Plan6.Range("B3").Value <= 10 And Plan6.Range("B3").Value = "Media" Then
Plan6.Range("B7").Value = 15
End If
If Plan6.Range("B3").Value >= 11 And Plan6.Range("B3").Value <= 20 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 18
End If
If Plan6.Range("B3").Value >= 11 And Plan6.Range("B3").Value <= 20 And Plan6.Range("B4").Value = "Media" Then
Plan6.Range("B7").Value = 30
End If
If Plan6.Range("B3").Value >= 21 And Plan6.Range("B3").Value <= 30 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 27
End If
If Plan6.Range("B3").Value >= 21 And Plan6.Range("B3").Value <= 30 And Plan6.Range("B4").Value = "Media" Then
Plan6.Range("B7").Value = 45
End If
If Plan6.Range("B3").Value >= 31 And Plan6.Range("B3").Value <= 40 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 36
End If
If Plan6.Range("B3").Value >= 31 And Plan6.Range("B3").Value <= 40 And Plan6.Range("B4").Value = "Media" Then
Plan6.Range("B7").Value = 60
End If
If Plan6.Range("B3").Value >= 41 And Plan6.Range("B3").Value <= 50 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 45
End If
If Plan6.Range("B3").Value >= 41 And Plan6.Range("B3").Value <= 50 And Plan6.Range("B4").Value = "Media" Then
Plan6.Range("B7").Value = 75
End If
If Plan6.Range("B3").Value >= 51 And Plan6.Range("B3").Value <= 60 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 54
End If
If Plan6.Range("B3").Value >= 51 And Plan6.Range("B3").Value <= 60 And Plan6.Range("B4").Value = "Media" Then
Plan6.Range("B7").Value = 90
End If
If Plan6.Range("B3").Value >= 61 And Plan6.Range("B3").Value <= 70 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 63
End If
If Plan6.Range("B3").Value >= 61 And Plan6.Range("B3").Value <= 70 And Plan6.Range("B4").Value = "Media" Then
Plan6.Range("B7").Value = 105
End If
If Plan6.Range("B3").Value >= 71 And Plan6.Range("B3").Value <= 85 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 70
End If
If Plan6.Range("B3").Value >= 71 And Plan6.Range("B3").Value <= 85 And Plan6.Range("B4").Value = "Media" Then
Plan6.Range("B7").Value = 110
End If
If Plan6.Range("B3").Value >= 86 And Plan6.Range("B3").Value <= 99 And Plan6.Range("B4").Value = "Baixa" Then
Plan6.Range("B7").Value = 99
End If
If Plan6.Range("B3").Value >= 86 And Plan6.Range("B3").Value <= 99 And Plan6.Range("B4").Value = "Media" Then
Plan6.Range("B7").Value = 110
End If
End Sub
Private Sub calcula_dias_2()
If Plan6.Range("G3").Value <= 10 And Plan6.Range("G4").Value = "Sistema Comum (WEB ou Cliente Servidor)" Then
Plan6.Range("G7").Value = Plan6.Range("G3").Value * 0.34
G8 = G7 * 22
End If
If Plan6.Range("G3").Value <= 10 And Plan6.Range("G4").Value <> "Sistema Comum (WEB ou Cliente Servidor)" Then
Plan6.Range("G7").Value = Plan6.Range("G3").Value * 0.37
Plan6.Range("G8").Value = Plan6.Range("G7").Value * 22
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$3" And Target.Address = "$B$4" Then
Call calcula_dias
Exit Sub
End If
End Sub
Aguardo,
Rafael