Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Ken G.
 
Posts: n/a
Default Format a Comment created by a Macro

Thanks to Ken Johnson's help I have a Comment box which appears only if a
condition is met. This comment has been created by a small macro. It seems
that because the comment box is not a standard Excel comment, but has been
created by the macro, any attempt to format the text box (dimensions,
alignment, no shadow etc) fails. It looks like the formatting has to be
included in the macro, but so far I haven't been able to do this. Can anyone
help?
  #2   Report Post  
mudraker
 
Posts: n/a
Default


Ken

can you post the code that creates the Comment box


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=400311

  #3   Report Post  
 
Posts: n/a
Default

mudraker,
If you are addressing Ken Johnson here is the code I posted for Ken.G.
If you're addressing Ken.G then please ignore this reply.

Just as a demo, if the value in cell A1 of the active sheet changes to
become greater than 10 then Cell B1 has the comment "A1 is greater than

10" added.
The code must be pasted into the ThisWorkbook module. If you don't
want all sheets affected then paste the code into the WorkSheet_Change

Sub of the sheet you want affected.
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
If ActiveSheet.Cells(1, 1).Value 10 Then
With ActiveSheet.Cells(1, 2)
On Error Resume Next 'if no comment to delete then error is
ignored
.Comment.Delete 'remove old comment
On Error GoTo 0
.AddComment
.Comment.Visible =3D True 'change to False if you only want to
see the comment
'when the cursor is positioned over the

commented cell
.Comment.Text Text:=3D"A1 is greater than 10"
.Comment.Shape.TextFrame.AutoS=ADize =3D True 'comment frame size
will suit any size comment
End With
Else: On Error Resume Next
ActiveSheet.Cells(1, 2).Comment.Delete 'delete old comment because A1
is not 10=20
On Error GoTo 0=20
End If=20
End Sub=20

Ken Johnson

  #4   Report Post  
Ken G.
 
Posts: n/a
Default

Don't ignore Ken Johnson's post. That's the code I used to create the
conditional comment. I've since tried recording a macro while creating and
formatting a comment, then copied that code into my macro but it keeps coming
up with errors. I don't know enough about vbasic I'm afraid.

"mudraker" wrote:


Ken

can you post the code that creates the Comment box


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=400311


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Button not bring up Macro I created A.S. Excel Discussion (Misc queries) 1 July 22nd 05 10:21 PM
Runtime error for macro that works in workbook created in Crystal Excel Discussion (Misc queries) 1 June 22nd 05 08:43 PM
ability to embed a macro within a csv n30 Excel Discussion (Misc queries) 3 April 3rd 05 06:03 AM
How do I set up the default format for a comment? Gitesh Excel Discussion (Misc queries) 1 April 1st 05 11:18 PM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM


All times are GMT +1. The time now is 07:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"