Caros,
Continuando na linha: "Revisitando As primeiras funções que desenvolvi".
DICA: Todas as funções que criarmos que tenham interação física direta nas planilhas que estivermos utilizando, terão uma performance muito melhor se colocarmos o comando Application.ScreenUpdating = False, antes do início do respectivo processamento.
- Como faço para Colorir o fundo das células de um range com cores alternadas?
Sub ShadeAlternR (rngTarget As Range, intColor As Integer, lngStep As Long)' Coloca a cor de fundo = intColor to every lngStep rows in rngTarget' example: ShadeAlternateRows Range("A1:D50"), 27, 2 (colors every 2 rows light yellow)
Dim r As LongLet Application.ScreenUpdating = False
If rngTarget Is Nothing Then Exit SubWith rngTarget.Interior.ColorIndex = xlColorIndexNone' remove any previous shadingFor r = lngStep To .Rows.Count Step lngStepLet .Rows(r).Interior.ColorIndex = intColorNext rEnd WithEnd Sub
Sub ShadeAlternC (rngTarget As Range, intColor As Integer, lngStep As Long)' Coloca a cor de fundo = intColor to every lngStep column in rngTarget' example: ShadeAlternateColumns Range("A1:J20"), 27, 2 (colors every 2 columns light yellow)
Dim c As LongLet Application.ScreenUpdating = FalseIf rngTarget Is Nothing Then Exit SubWith rngTarget.Interior.ColorIndex = xlColorIndexNone' remove any previous shadingFor c = lngStep To .Columns.Count Step lngStepLet .Columns(c).Interior.ColorIndex = intColorNext cEnd WithEnd Sub
André Luiz Bernardes
A&A® - Work smart, not hard in any place.
Skype: inanyplace