+ Reply to Thread
Results 1 to 4 of 4

[SOLVED] Format a Comment created by a Macro

  1. #1
    Ken G.
    Guest

    [SOLVED] 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. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Ken

    can you post the code that creates the Comment box

  3. #3

    Re: Format a Comment created by a Macro

    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. #4
    Ken G.
    Guest

    Re: Format a Comment created by a Macro

    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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1