Views

Histats

Vitrine

VBA Excel - Manipule Ícones nas suas Planilhas - Add Icon Sets for Ranges

Este exemplo mostra como adicionar ícones num determinado intervalo de valores no workbook.

Se você se perguntar prá que precisar saber isso, não está pronto para aprendê-lo...


Sub TestAddIconSet() 
  Dim i As Integer 
  Dim rng As Range 

  For i = 1 To 20 
    ' Set up ranges 
    Set rng = SetupRange(i) 
    Select Case i 
      Case 1 
        SetUpIconSet rng, xl3Arrows 
      Case 2 
        SetUpIconSet rng, xl3ArrowsGray 
      Case 3 
        SetUpIconSet rng, xl3Flags 
      Case 4 
        SetUpIconSet rng, xl3Signs 
      Case 5 
        SetUpIconSet rng, xl3Stars 
      Case 6 
        SetUpIconSet rng, xl3Symbols 
      Case 7 
        SetUpIconSet rng, xl3Symbols2 
      Case 8 
        SetUpIconSet rng, xl3TrafficLights1 
      Case 9 
        SetUpIconSet rng, xl3TrafficLights2 
      Case 10 
        SetUpIconSet rng, xl3Triangles 
      Case 11 
        SetUpIconSet rng, xl4Arrows 
      Case 12 
        ' Reverse the order on this one: 
        SetUpIconSet rng, xl4ArrowsGray, True 
      Case 13 
        SetUpIconSet rng, xl4CRV 
      Case 14 
        SetUpIconSet rng, xl4RedToBlack 
      Case 15 
        SetUpIconSet rng, xl4TrafficLights 
      Case 16 
        SetUpIconSet rng, xl5Arrows 
      Case 17 
        ' Reverse the order on this one: 
        SetUpIconSet rng, xl5ArrowsGray, True 
      Case 18 
        SetUpIconSet rng, xl5Boxes 
      Case 19 
        SetUpIconSet rng, xl5CRV 
      Case 20 
        SetUpIconSet rng, xl5Quarters 
    End Select 
  Next i 
End Sub 
 
Function SetupRange(col As Integer) As Range 
    ' Set up ranges, filled with numbers from 1 to 10. 
    Set rng = Range(Cells(1, col), Cells(10, col)) 
    
    Dim rng1 As Range 
    Set rng1 = Cells(1, col) 
    rng1.Value = 1 
 
    Dim rng2 As Range 
    Set rng2 = Cells(2, col) 
    rng2.Value = 2 
    
    Range(rng1, rng2).AutoFill Destination:=rng 
    Set SetupRange = rng 
End Function 
 
Sub SetUpIconSet(rng As Range, iconSet As XlIconSet, Optional ReverseOrder As Boolean = False) 
    ' Set up an icon set for the supplied range. 
    rng.FormatConditions.Delete 
    Dim isc As IconSetCondition 
    Set isc = rng.FormatConditions.AddIconSetCondition 
    With isc 
        ' If specified, show the icons in the reverse ordering: 
        .ReverseOrder = ReverseOrder 
        .ShowIconOnly = False 
        ' Select the requested icon set: 
        .iconSet = ActiveWorkbook.IconSets(iconSet) 
    End With 
End Sub 


Deixe os seus comentários! Envie este artigo, divulgue este link na sua rede social...

Tags
VBA, Excel, Icon, ícones, Conditional, Formatting, 



LinkWithinBrazilVBAExcelSpecialist

Related Posts Plugin for WordPress, Blogger...