Adicionado em: | 19/11/2010 |
Modificado em: | 19/11/2010 |
Tamanho: | Vazio |
Downloads: | 730 |
SaberExcel VBA Estudos®
Essa macro do Aplicativo Microsoft Excel VBA, insere um comentário formatado em vermelho, na célula ativa da folha de planilha, o retorno do comentário é auxiliado por uma inputbox,
Option Explicit
Sub Comentario_Celula()
Dim rnCell As Range
Dim SbNome As String
Dim vlr_Comentario As Variant
Dim iEventos As Integer
Dim resposta As String
SbNome = Application.UserName
Set rnCell = ActiveCell
With rnCell
'Caso nao exista comentario na celula
resposta = MsgBox("Deseja inserir um comentario na célula ativa?", vbYesNo, "Saberexcel - site das macros")
If resposta = vbYes Then
If .Comment Is Nothing Then
'Comentario digitado pelo usuario
vlr_Comentario = Application.InputBox _
("Digite seu comentario:", "Comentario na celula e formata", Default:="Saberexcel.com", Type:=2)
'fecha a caixa de dialogo com o botao cancelar
If vlr_Comentario = False Then Exit Sub
'Aqui é o nome do usuario e o comentario da celula
.AddComment Text:=SbNome & ":" & vbLf & vlr_Comentario
'Aqui formata a celula do comentario
With .Comment.Shape.TextFrame
With .Characters.Font
.Size = 11
.ColorIndex = 3
.Name = "Arial"
End With
.AutoSize = True
'o nome do usuario em negrito
.Characters(Start:=1, Length:=Len(SbNome)).Font.Bold = True
End With
Else
'verifica se a celula já tem comentario
iEventos = MsgBox("Deseja remover a célula comentário ?", vbYesNoCancel, "Excluir Comentario")
Select Case iEventos
Case vbYes
.Comment.Delete
Exit Sub
Case vbCancel
Exit Sub
Case vbNo
vlr_Comentario = Application.InputBox _
("Digite o texto comentar aqui :", "Inserir / Editar célula comentário ", Default:="Saberexcel.com", Type:=2)
If vlr_Comentario = False Then Exit Sub
.Comment.Delete
.AddComment Text:=SbNome & ":" & vbLf & vlr_Comentario
End Select
End If
End If
End With
Application.DisplayCommentIndicator = xlCommentIndicatorOnly
End Sub
Aprenda tudo sobre Aplicativo Microsoft Excel VBA com Saberexcel
Baixe o exemplo de planilha contendo a macro acima
Publicidade:
Compre com segurança, garantia e preços baixos nas lojas submarino
Adicionado em: | 19/11/2010 |
Modificado em: | 19/11/2010 |
Tamanho: | Vazio |
Downloads: | 564 |
SaberExcel - o site das macros
Esta macro do Aplicativo Microsoft Excel VBA, insere um comentário falso na folha de planilha,
isto é insere autoformas que imitam um comentário, um pequeno triângulo vermelho representando
o indicador do comentário (no canto superior esquerdo da célula) e um retangulo contendo o comentário
propriamente dito, obtido atraves de um inputbox(entrada de dados).
Sub Falso_Comentario()
Dim com As String
Dim aSh As Worksheet
Dim cloneC As Shape
com = InputBox("Insira seu comentário.....", "Inserir comentário que será falso")
If com <> "" Then
On Error Resume Next
With Selection.Validation
.Add Type:=xlValidateInputOnly
.InputTitle = "Falso comentário :"
.InputMessage = com
End With
Else: Exit Sub
End If
Application.ScreenUpdating = False
Set aSh = ActiveSheet
Set poZ = ActiveCell
p1 = poZ.Top
p2 = poZ.Left
Set cloneC = aSh.Shapes.AddShape(msoShapeRightTriangle, _
p2, p1, 5#, 5#)
With cloneC
.IncrementRotation 90#
.Fill.ForeColor.SchemeColor = 10
.Line.Visible = msoFalse
End With
End Sub
Aprenda Aplicativo Microsoft Excel VBA --((SaberExcel))--
Adicionado em: | 19/11/2010 |
Modificado em: | 19/11/2010 |
Tamanho: | Vazio |
Downloads: | 413 |
Saberexcel - o site das macros
Caro E_Marcondes, sou programador e preciso de uma macro, que insere um triângulo azul no lugar do indicador(vermelho) do comentário,
eu tinha mas acabei perdendo, se você tiver, será que poderia me enviar, obrigado. Reginaldo
Sim tenho sim, junto à minha coleção de 15.000 macros achei, na verdade é uma macro servida de uma função:
Cor do triângulo do indicador do comentário em azul
'Option Explicit
Sub Criar_triangulo_indicador_comentario()
vCriarIndicador vbBlue, "EPM"
End Sub
Public Function vCriarIndicador(CommentIndicatorColor As Long, _
CommentIndicatorName As String) As Boolean
'
Dim IDnumber As Long
Dim aCell As Range
Dim aComment As Comment
Dim aShape As Shape
Dim aWorksheet As Worksheet
Dim aWorkbook As Workbook
vCriarIndicador = False
If CommentIndicatorName = vbNullString Then GoTo ExitFunction
On Error GoTo ExitFunction
Set aWorkbook = ActiveWorkbook
IDnumber = 0
'loop through all wprksheets in the active workbook and all comments
'in each worksheet and create the comment shapes
For Each aWorksheet In aWorkbook.Worksheets
For Each aShape In aWorksheet.Shapes
If Left(aShape.Name, Len(CommentIndicatorName)) = _
CommentIndicatorName Then
aShape.Delete
End If
Next aShape
For Each aComment In aWorksheet.Comments
Set aCell = aComment.Parent
If InStr(1, aComment.Shape.TextFrame.Characters.Text, ":") > 0 Then
If Left(aComment.Shape.TextFrame.Characters.Text, InStr(1, aComment.Shape.TextFrame.Characters.Text, ":") - 1) = Application.UserName Then
GoSub CreateCommentIndicator
End If
End If
Next aComment
Next aWorksheet
vCriarIndicador = True
ExitFunction:
On Error GoTo 0
Set aCell = Nothing
Set aComment = Nothing
Set aShape = Nothing
Set aWorksheet = Nothing
Set aWorkbook = Nothing
Exit Function
CreateCommentIndicator:
Set aShape = aWorksheet.Shapes.AddShape(Type:=msoShapeRightTriangle, _
Left:=aCell.Left + aCell.Width - 5, _
Top:=aCell.Top, _
Width:=5, _
Height:=5)
IDnumber = IDnumber + 1
With aShape
.Name = CommentIndicatorName & CStr(IDnumber)
.IncrementRotation -180#
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.RGB = CommentIndicatorColor
.Line.Visible = msoTrue
.Line.Weight = 1
.Line.Style = msoLineSingle
.Line.DashStyle = msoLineSolid
.Line.ForeColor.RGB = CommentIndicatorColor
.Placement = xlMove
End With
Return
End Function
Aprenda Microsoft Excel VBA (( Saberexcel ))
Adicionado em: | 19/11/2010 |
Modificado em: | 19/11/2010 |
Tamanho: | Vazio |
Downloads: | 748 |
Saberexcel - site das macros
Macro do Aplicativo Microsofoft Excel VBA, formata o comentário em uma determinada planilha com a cor verde de fundo e a fonte em azul é.
Sub formata_cores_comentario()
Dim Wsh As Worksheet, vComentario As Comment
For Each Wsh In Worksheets
For Each vComentario In Wsh.Comments
vComentario.Shape.OLEFormat.Object.AutoSize = True
With vComentario.Shape.OLEFormat.Object.Font
.Name = "Tahoma"
.Size = 10
.ColorIndex = 5 'cor número cinco refere-se a cor Azul
End With
vComentario.Shape.OLEFormat.Object.ShapeRange.Fill _
.ForeColor.SchemeColor = 42 '
Next vComentario
Next Wsh
End Sub
Aprenda Microsoft Excel VBA (( SaberExcel ))
Adicionado em: | 19/11/2010 |
Modificado em: | 19/11/2010 |
Tamanho: | Vazio |
Downloads: | 773 |
Inserir um gráfico no comentário na celula (a1)
Esta macro pega o gráfico da plan1, e insere no comentário na célula A1 da Plan1, forneça para macro o endereço "Path" Diretório correto onde irá salvar o gráfico. Primeiro crie o gráfico que deseja exportar para o diretório, e automaticamente, inserir no comentário na célula(A1)
Sub Insere_Image_Grafico_dentro_comentario_CelulaA1()
Dim vMinhaImagem As String
Dim vGrafico As ChartObject
Dim Altura As Single, Largura As Single
vMinhaImagem = "C:\vba\imagem_escolhida.gif" ' vai exportar essa imagem do gráfico criado para esse dir
'Define sobre o gráfico dentro da Planilha Plan1
Set vGrafico = Plan1.ChartObjects(1)
'Exporta o gráfico criado como GIF
vGrafico.Chart.Export vMinhaImagem, "GIF"
'recupera a dimensão do gráfico para aplicar no comentário
Altura = vGrafico.Height
Largura = vGrafico.Width
'Verifica se já existe um comentário na celula A1
'e deleta se existe
If Not Plan1.Range("A1").Comment Is Nothing Then _
Plan1.Range("A1").Comment.Delete
'Criar um novo comentário na célula a1
With Plan1.Range("A1")
.AddComment
.Comment.Visible = False
'Define a altura do comentário do grafico
.Comment.Shape.Height = Altura
'Define a largura do comentário
.Comment.Shape.Width = Largura
'Insere a imagem dentro do comentário
.Comment.Shape.Fill.UserPicture vMinhaImagem
End With
'deleta a imagem exportada
Kill vMinhaImagem
'deleta o gráfico
vGrafico.Delete
End Sub
Adquira já o Acesso Imediato
à Area de Membros
Aprenda Excel VBA com Simplicidade de
códigos e Eficácia, Escrevendo Menos e
Fazendo Mais.
'-------------------------------------'
Entrega Imediata:
+ 500 Video Aulas MS Excel VBA
+ 35.000 Planilhas Excel e VBA
+ Coleção 25.000 Macros MS Excel VBA
+ 141 Planilhas Instruções Loops
+ 341 Planilhas WorksheetFunctions(VBA)
+ 04 Módulos Como Fazer Excel VBA
+ Curso Completo MS Excel VBA
+ Planilhas Inteligentes
<script type="text/javascript"><!--
google_ad_client = "ca-pub-2317234650173689";
/* retangulo 336 x 280 */
google_ad_slot = "0315083363";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
Aprenda tudo sobre o Aplicativo Microsoft Excel VBA(Visual Basic Application), sozinho, com baixo custo, praticando com os produtos didáticos Saberexcel,
Sobre as WorksheetFunctions Funções de Planilhas que retornam valores do VBA