Excel planilha vba comentario insere shapes numerando os comentarios cores

Sex, 19 de Novembro de 2010 19:58 Expedito Marcondes
Imprimir

Saberexcel - site das macros

Macros do Aplicativo Microsoft Excel VBA, insere shapes númerados nos comentários.

Sub inserir_shapes_numerados()

Dim Wsh As Worksheet
Dim cmt As Comment
Dim lCmt As Long
Dim rngCmt As Range
Dim shpCmt As Shape
Dim shpW As Double 'shape width
Dim shpH As Double 'shape height

Set Wsh = ActiveSheet
shpW = 8
shpH = 6
lCmt = 1

For Each cmt In Wsh.Comments
Set rngCmt = cmt.Parent
With rngCmt
Set shpCmt = Wsh.Shapes.AddShape(msoShapeRectangle, _
rngCmt.Offset(0, 1).Left - shpW, .Top, shpW, shpH)
End With
With shpCmt
With .Fill
.ForeColor.SchemeColor = 2 'white
.Visible = msoTrue
.Solid
End With
With .Line
.Visible = msoTrue
.ForeColor.SchemeColor = 64 'automatic
.Weight = 0.25
End With
With .TextFrame
.Characters.Text = lCmt
.Characters.Font.Size = 4
.MarginLeft = 0#
.MarginRight = 0#
.MarginTop = 0#
.MarginBottom = 0#
.HorizontalAlignment = xlCenter
End With
.Top = .Top + 0.001
End With
lCmt = lCmt + 1
Next cmt

End Sub

Esta macro remove os indicadores(shapes) inseridos nos comentários
Sub Remove_indicador_shapes()

Dim Wsh As Worksheet
Dim shp As Shape

Set Wsh = ActiveSheet

For Each shp In Wsh.Shapes
If Not shp.TopLeftCell.Comment Is Nothing Then
If shp.AutoShapeType = _
msoShapeRectangle Then
shp.Delete
End If
End If
Next shp

End Sub

Esta macro relaciona os comentários em uma folha de planilha separada, numero, nome, valor, e endereço do comentário
Sub Relacionar_comentarios()
Application.ScreenUpdating = False

Dim commrange As Range
Dim cmt As Comment
Dim Atual_Plan As Worksheet
Dim nova_plan As Worksheet
Dim i As Long

Set Atual_Plan = ActiveSheet

On Error Resume Next
Set commrange = Atual_Plan.Cells _
.SpecialCells(xlCellTypeComments)
On Error GoTo 0

If commrange Is Nothing Then
MsgBox "nao foi encontrado comentários"
Exit Sub
End If

Set nova_plan = Worksheets.Add

nova_plan.Range("A1:D1").Value = _
Array("Numero", "Nome", "Valor", "Comentário")

i = 1
For Each cmt In Atual_Plan.Comments
With nova_plan
i = i + 1
On Error Resume Next
.Cells(i, 1).Value = i - 1
.Cells(i, 2).Value = cmt.Parent.Name.Name
.Cells(i, 3).Value = cmt.Parent.Value
.Cells(i, 4).Value = cmt.Parent.Address
.Cells(i, 5).Value = Replace(cmt.Text, Chr(10), " ")
End With
Next cmt

nova_plan.Cells.WrapText = False
nova_plan.Columns.AutoFit

Application.ScreenUpdating = True

End Sub

 


Aprenda tudo sobre o Aplicativo Microsoft Excel VBA(Visual Basic Application), sozinho, com baixo custo, praticando com os produtos didáticos Saberexcel



   Baixe o exemplo de planilha da macro acima
 vExcel planilha vba comentario insere shapes numerando os comentarios cores (26.99 kB)



Publicidade
Compre com segurança, garantia e ótimos preços
Eletrônicos - Submarino.com.br

Tags:
Última atualização em Qua, 10 de Agosto de 2011 08:20