Ir ao conteúdo
  • Cadastre-se

Macro para pintar rótulo de dados em gráfico


Carol1985

Posts recomendados

Patropi, olha só...achei este link com uma planilha que faz algo parecido com o que eu necessito. Toda vez que o valor no rótulo de dados for maior que 100% ele deixa a cor do texto do rótulo de dados em vermelho e em negrito, mas não pinta aquela caixa do rótulo.

O link é http://www.4shared.com/file/p3svVSfd/frmtLBL.html

Seria possível adaptar esta macro? Segue o código da mesma (bom, copiei tudo que estava no módulo);

Sub Rotular()

Call Macro1

Call Macro2

End Sub

Sub Macro1()

Dim lbl As DataLabel

ActiveSheet.ChartObjects("Gráfico 5").Activate

ActiveChart.SeriesCollection(1).DataLabels.Select

i = 1

For Each lbl In ActiveChart.SeriesCollection(1).DataLabels

ActiveChart.SeriesCollection(1).Points(i).DataLabel.Select

x = lbl.Text

If x <> "" Then

t = Len(x)

y = Mid(x, 1, t - 1)

If CDbl(y) > 100 Then

With Selection.Format.TextFrame2.TextRange.Font

.Fill.ForeColor.RGB = RGB(255, 0, 0)

.Bold = msoTrue

End With

Else

With Selection.Format.TextFrame2.TextRange.Font

.Fill.ForeColor.RGB = RGB(255, 255, 255)

.Bold = msoFalse

End With

End If

End If

i = i + 1

Next

End Sub

Sub Macro2()

Dim lbl As DataLabel

ActiveSheet.ChartObjects("Gráfico 5").Activate

ActiveChart.SeriesCollection(1).DataLabels.Select

i = 1

For Each lbl In ActiveChart.SeriesCollection(2).DataLabels

ActiveChart.SeriesCollection(2).Points(i).DataLabel.Select

x = lbl.Text

If x <> "" Then

t = Len(x)

y = Mid(x, 1, t - 1)

If CDbl(y) > 100 Then

With Selection.Format.TextFrame2.TextRange.Font

.Fill.ForeColor.RGB = RGB(255, 0, 0)

.Bold = msoTrue

End With

Else

With Selection.Format.TextFrame2.TextRange.Font

.Fill.ForeColor.RGB = RGB(255, 255, 255)

.Bold = msoFalse

End With

End If

End If

i = i + 1

Next

End Sub

Obrigada.

Link para o comentário
Compartilhar em outros sites

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!