need specialist eye for the following macros.
need specialist eye for the following macros.
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 8 of 8

Thread: need specialist eye for the following macros.

  1. #1
    New Member
    Join Date
    Mar 2002
    Location
    rejdus@hotmail.com
    Posts
    18
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Macro i used to insert commentbox is:
    Sub Button25_Click()
    '
    ' Button25_Click Macro
    ' Macro recorded 11/04/2002 by Radek Ilendo
    '

    '
    Range("I12").Select
    Range("I12").AddComment
    Range("I12").Comment.Visible = True
    Range("I12").Comment.Text Text:="1." & Chr(10) & "2." & Chr(10) & "3." & Chr(10) & ""
    Range("I12").Select
    ActiveCell.Comment.Visible = False
    Range("I13").Select
    End Sub

    The problem i have is with the second line:
    Range("I12").AddComment
    as it is always requires debuging and makes macro not working i dunno wot is going wrong.

    Could any1 help.
    This is one of my latest step to finish my project
    luckily.

  2. #2
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I would assume that since you are "Select"-ing the cell, you don't need to to use Rang("I12") at all, you could just use "Selection".


    Posted: 2002-04-11 13:18
    --------------------------------------------------------------------------------
    Macro i used to insert commentbox is:
    Sub Button25_Click()
    '
    ' Button25_Click Macro
    ' Macro recorded 11/04/2002 by Radek Ilendo
    '

    '
    Range("I12").Select
    Selection.AddComment
    Selection.Comment.Visible = True
    Selection.Comment.Text Text:="1." & Chr(10) & "2." & Chr(10) & "3." & Chr(10) & ""
    'Range("I12").Select
    ActiveCell.Comment.Visible = False
    Range("I13").Select
    End Sub



    HTH

  3. #3
    New Member
    Join Date
    Mar 2002
    Location
    rejdus@hotmail.com
    Posts
    18
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Mark
    Selection.AddComment
    doesnt change anything code is still frozen and reqiures debuging.
    thnx 4 help
    any1 with anymore ideas?
    pls.

  4. #4
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I didn't test the code.

    What error are you getting? i.e. why is it telling you that it needs debugging?

    You're original code works for me. What version of Excel are you using? I've got XL2000.
    _________________
    [b] Mark O'Brien

    [ This Message was edited by: Mark O'Brien on 2002-04-11 13:37 ]

  5. #5
    New Member
    Join Date
    Mar 2002
    Location
    rejdus@hotmail.com
    Posts
    18
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    run-time error '1004':
    application-defined or object-defined error


    dis drives me mad
    im using excel 2000 as well
    i dunno wot may go wrong all i have problem with is that second line
    Selection.AddComment or
    my version
    Range("I12").AddComment

    anything else u could suggest
    pls

  6. #6
    New Member
    Join Date
    Mar 2002
    Location
    rejdus@hotmail.com
    Posts
    18
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    begging for help//



    maybe any1 could suggest their own macro to input the commentbox into a specified cell.

  7. #7
    MrExcel MVP Jay Petrulis's Avatar
    Join Date
    Mar 2002
    Location
    Chicago, IL USA
    Posts
    2,040
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi,

    I assume that you are getting an error because you are trying to add a comment to a cell that already contains a comment.

    I don't see a .HasComment property, but the following should resolve your problem...

    ------------------
    With Range("I12")
    .ClearComments
    .AddComment
    .Comment.Text Text:="1." & Chr(10) & "2." & Chr(10) & "3." & Chr(10) & ""
    .Comment.Visible = True
    End With
    ------------------

    If you don't want to show the comment, take the last line out (the default is false so the line is not needed).

    HTH,
    Jay

  8. #8
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    This worked for me;



    Private Sub CommandButton1_Click()

    With ActiveCell
    On Error Resume Next
    .Comment.Delete
    On Error GoTo 0
    .AddComment
    .Comment.Text Text:="1." & Chr(10) & "2." & Chr(10) & "3." & Chr(10) & ""
    End With

    End Sub




    Kind Regards,
    Ivan F Moala From the City of Sails

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com