Como mudar cor/cores no excel via macro?
Citação de Kindrazki em 19 de abril de 2012, 18:12Como mudar cor/cores no excel via macro?
[code]
Sub formatalucratividade()
Dim Sheet As Worksheet
Dim celula As Range
Dim endereco As String
Dim lMaxRows As Integer
lMaxRows = Cells(Rows.Count, "A").End(xlUp).RowApplication.Calculation = xlCalculationManual
For Each celula In Range("Z6:Z" '& lMaxRows)
endereco = celula.RowIf celula.Value < 10 Then
celula.Font.ColorIndex = 3
End IfIf celula.Value >= 10 Then
celula.Font.ColorIndex = 5
End IfNext
End Sub
[/code]Uma vez a Macro criada, poderá fazer a chamada dela em qualquer evento do excel: call NOMEMACRO
Como mudar cor/cores no excel via macro?
[code]
Sub formatalucratividade()
Dim Sheet As Worksheet
Dim celula As Range
Dim endereco As String
Dim lMaxRows As Integer
lMaxRows = Cells(Rows.Count, "A").End(xlUp).Row
Application.Calculation = xlCalculationManual
For Each celula In Range("Z6:Z" '& lMaxRows)
endereco = celula.Row
If celula.Value < 10 Then
celula.Font.ColorIndex = 3
End If
If celula.Value >= 10 Then
celula.Font.ColorIndex = 5
End If
Next
End Sub
[/code]
Uma vez a Macro criada, poderá fazer a chamada dela em qualquer evento do excel: call NOMEMACRO