Descricao: |
Escola Saberexcel VBA Estudos® - Treinamentos com Macros, Fórmulas e Funções
 Esses macros do aplicativo Microsoft Excel VBA(Visual Basic Application), contém a instrução If...ElseIF, que compara faixa de números, retorna uma mensagem na Coluna seguinte e colore os interiores das células com cores personalizadas de acordo com faixa. Espero que o exemplo seja util. Fique com Deus, Expedito Marcondes
Sub verifica_numeros_faixa() Range("C3:C" & Range("a5000").End(xlUp).Row).Clear copiar_valores For i = 3 To Cells(Rows.Count, "a").End(xlUp).Row If Cells(i, "a").Value > 100 And Cells(i, "a").Value < 200 Then Cells(i, "c").Value = "entre 100 e 200" Cells(i, "c").Interior.ColorIndex = 4 ElseIf Cells(i, "a").Value > 200 And Cells(i, "a").Value < 300 Then Cells(i, "c").Value = "entre 200 e 300" Cells(i, "c").Interior.ColorIndex = 36 ElseIf Cells(i, "a").Value > 300 And Cells(i, "a").Value < 400 Then Cells(i, "c").Value = "entre 300 e 400" Cells(i, "c").Interior.ColorIndex = 33 ElseIf Cells(i, "a").Value > 400 And Cells(i, "a").Value < 500 Then Cells(i, "c").Value = "entre 400 e 500" Cells(i, "c").Interior.ColorIndex = 33 ElseIf Cells(i, "a").Value > 500 And Cells(i, "a").Value < 600 Then Cells(i, "c").Value = "entre 500 e 600" Cells(i, "c").Interior.ColorIndex = 35 ElseIf Cells(i, "a").Value > 600 And Cells(i, "a").Value < 700 Then Cells(i, "c").Value = "entre 600 e 700" Cells(i, "c").Interior.ColorIndex = 40 ElseIf Cells(i, "a").Value > 700 And Cells(i, "a").Value < 800 Then Cells(i, "c").Value = "entre 700 e 800" Cells(i, "c").Interior.ColorIndex = 45 ElseIf Cells(i, "a").Value > 800 And Cells(i, "a").Value < 900 Then Cells(i, "c").Value = "entre 800 e 900" Cells(i, "c").Interior.ColorIndex = 39 Else Cells(i, "c").Value = "acima de 900" Cells(i, "c").Interior.ColorIndex = 10 End If Next i End Sub Sub copiar_valores() Range("I3:I25").Copy [a3] Range("a3:a25").Value = Range("a3:a25").Value Range("A3:A25").NumberFormat = "0.00" End Sub
Sub cores_vba() For i = 1 To 55 Cells(i, "a").Interior.ColorIndex = i Cells(i, "b").Value = i Next i End Sub Sub limpa_cores() Cells.Clear End Sub Sub visualiza_macro() ActiveSheet.Shapes.Range(Array("macro")).Select Selection.Verb Verb:=xlPrimary Range("e1").Select End Sub
 Aprenda tudo sobre planilhas do Aplicativo Microsoft Excel VBA(Visual Basic Application), sozinho, com baixo custo, praticando com os produtos didáticos Escola Saberexcel VBA Estudos® - Treinamentos com Macros, Fórmulas e Funções.

|