Você está na página 1de 3

• Sub Calculo

Dim peso As Single, altura As Single


peso = InputBox("Digite o peso", "Cálculo IMC")
altura = InputBox("Digite a altura", "Cálculo IMC")
MsgBox "Seu IMC é " & peso / altura ^ 2, vbInformation, "Cálculo IMC"

• Sub Analise
Dim IMC As Single
IMC = InputBox("Digite o IMC", "Análise")
If IMC > 25 Then
MsgBox "Inadequado", vbCritical, "Análise"
Else
MsgBox "Adequado", vbInformation, "Análise"
End If

• Sub Verificar
Dim IMC As Single
IMC = InputBox("Digite o IMC", "Verificar")
If IMC < 20 Then
MsgBox "Baixo", vbInformation, "Verificar"
ElseIf IMC < 25 Then
MsgBox "Normal", vbInformation, "Verificar"
Else
MsgBox "Alto", vbInformation, "Verificar"
End If

• Sub Temperatura
Dim temp As Single
temp = InputBox("Digite a temperatura", "Temperatura")
If temp < 18 Then
MsgBox "Hoje está frio", vbInformation, "Temperatura"
ElseIf temp <= 26 Then
MsgBox "Hoje a temperatura está amena", vbInformation, "Temperatura"
Else
MsgBox "Hoje faz calor", vbInformation, "Temperatura"
End If

• Sub Temperatura
Dim IMC As Single
IMC = InputBox("Digite o IMC", "Situação")
Select Case IMC
Case Is < 20
MsgBox "Baixo", vbCritical, "Situação"
Case Is < 25
MsgBox "Normal", vbCritical, "Situação"
Case Else
MsgBox "Alto", vbCritical, "Situação"
End Select
• Sub Situacao
Dim IMC As Single
IMC = InputBox("Digite o IMC", "Situação")
Select Case IMC
Case Is < 20
MsgBox "Baixo", vbCritical, "Situação"
Case Is < 25
MsgBox "Normal", vbCritical, "Situação"
Case Else
MsgBox "Alto", vbCritical, "Situação"
End Select

• Sub Previsao
Select Case InputBox("Digite a temperatura", "Previsão")
Case Is < 20
MsgBox "Hoje está frio", vbInformation, "Previsão"
Case Is < 25
MsgBox "Hoje a temperatura está amena", "Previsão"
Case Else
MsgBox "Hoje faz calor", vbInformation, "Previsão"
End Select

• Sub Notas
Select Case InputBox("Digite a média final do aluno", "Notas")
Case Is < 6
MsgBox "Reprovado", vbInformation, "Notas"
Case 6 To 8
MsgBox "Regular", vbInformation, "Notas"
Case Else
MsgBox "Ótimo", vbInformation, "Notas"
End Select

• Sub Tabela
Worksheets("Massa").Select
Range("D3").Select
If Range("C3").Value < 20 Then
ActiveCell.Value = "Baixo"
ActiveCell.Font.Color = vbBlue
ElseIf Range("C3").Value < 25 Then
ActiveCell.Value = "Normal"
ActiveCell.Font.Color = vbGreen
Else
ActiveCell.Value = "Alto"
ActiveCell.Font.Color = vbRed
End If

• Sub Soma
Dim contador As Integer, Soma As Integer
For contador = 1 To 10
Soma = Soma + contador
Next
MsgBox "A soma é " & Soma
• Sub Inicial
Dim contador As Integer
For contador = 2 To 23
Cells(contador, 2).Value = Left(Cells(contador, 3), 1)
Next

• Sub Turmas
Range("C2").Select
Do While ActiveCell.Value <> ""
If ActiveCell.Offset(0, -1).Value <= "J" Then
ActiveCell.Offset(0, -2).Value = "Turma A"
ElseIf ActiveCell.Offset(0, -1).Value <= "N" Then
ActiveCell.Offset(0, -2).Value = "Turma B"
Else
ActiveCell.Offset(0, -2).Value = "Turma C"
End If
ActiveCell.Offset(1, 0).Select
Loop

• Sub Resultado
Worksheets("Notas").Select
Range("H2").Select
Do Until ActiveCell.Offset(0, -1).Value = ""
If ActiveCell.Offset(0, -1).Value < 6 Or ActiveCell.Offset(0, -2).Value > 5
Then
ActiveCell.Value = "Reprovado"
ActiveCell.Font.Color = vbRed
Else
ActiveCell.Value = "Aprovado"
ActiveCell.Font.Color = vbBlue
End If
ActiveCell.Offset(1, 0).Select
Loop

• Sub Preencher
Dim celula As Range
Worksheets("Notas").Select
For Each celula In Range("G2:G23")
If celula.Value < 6 Then
celula.Interior.Color = 11851260
ElseIf celula.Value < 7.5 Then
celula.Interior.Color = 10092543
Else
celula.Interior.Color = 12379352
End If
Next

Você também pode gostar