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 IntegerDim rng As RangeFor i = 1 To 20' Set up rangesSet rng = SetupRange(i)Select Case iCase 1SetUpIconSet rng, xl3ArrowsCase 2SetUpIconSet rng, xl3ArrowsGrayCase 3SetUpIconSet rng, xl3FlagsCase 4SetUpIconSet rng, xl3SignsCase 5SetUpIconSet rng, xl3StarsCase 6SetUpIconSet rng, xl3SymbolsCase 7SetUpIconSet rng, xl3Symbols2Case 8SetUpIconSet rng, xl3TrafficLights1Case 9SetUpIconSet rng, xl3TrafficLights2Case 10SetUpIconSet rng, xl3TrianglesCase 11SetUpIconSet rng, xl4ArrowsCase 12' Reverse the order on this one:SetUpIconSet rng, xl4ArrowsGray, TrueCase 13SetUpIconSet rng, xl4CRVCase 14SetUpIconSet rng, xl4RedToBlackCase 15SetUpIconSet rng, xl4TrafficLightsCase 16SetUpIconSet rng, xl5ArrowsCase 17' Reverse the order on this one:SetUpIconSet rng, xl5ArrowsGray, TrueCase 18SetUpIconSet rng, xl5BoxesCase 19SetUpIconSet rng, xl5CRVCase 20SetUpIconSet rng, xl5QuartersEnd SelectNext iEnd SubFunction 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 RangeSet rng1 = Cells(1, col)rng1.Value = 1Dim rng2 As RangeSet rng2 = Cells(2, col)rng2.Value = 2Range(rng1, rng2).AutoFill Destination:=rngSet SetupRange = rngEnd FunctionSub SetUpIconSet(rng As Range, iconSet As XlIconSet, Optional ReverseOrder As Boolean = False)' Set up an icon set for the supplied range.rng.FormatConditions.DeleteDim isc As IconSetConditionSet isc = rng.FormatConditions.AddIconSetConditionWith isc' If specified, show the icons in the reverse ordering:.ReverseOrder = ReverseOrder.ShowIconOnly = False' Select the requested icon set:.iconSet = ActiveWorkbook.IconSets(iconSet)End WithEnd Sub
Deixe os seus comentários! Envie este artigo, divulgue este link na sua rede social...
Tags: VBA, Excel, Icon, ícones, Conditional, Formatting,
Nenhum comentário:
Postar um comentário