+ Reply to Thread
Results 1 to 6 of 6

Instant Comment Box

Hybrid View

Sanecrazy Instant Comment Box 03-07-2012, 09:57 AM
Kelshaer Re: Instant Comment Box 03-07-2012, 10:03 AM
davesexcel Re: Instant Comment Box 03-07-2012, 10:07 AM
Kelshaer Re: Instant Comment Box 03-07-2012, 10:24 AM
davesexcel Re: Instant Comment Box 03-07-2012, 10:33 AM
Kelshaer Re: Instant Comment Box 03-07-2012, 10:38 AM
  1. #1
    Registered User
    Join Date
    07-19-2011
    Location
    Derby
    MS-Off Ver
    Excel 2003
    Posts
    41

    Instant Comment Box

    Hi im after a simple bit of code so that when i enter the number 6111 in a certain colunm, say colunm A:A that the cell that 6111 is entered will automaticly show a comment box saying "Attention"

    Shouldnt be hard for you guys?

    Cheers

    Sane

  2. #2
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: Instant Comment Box

    use this in the code page of the desired sheet

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Value = 6111 Then Target.AddComment ("Attention")
    End Sub
    Regards,
    Khaled Elshaer
    www.BIMcentre.com

    Remember To Do the Following....
    1. Thank those who have helped you by clicking the Star below their post.
    2. Mark your post SOLVED if it has been answered satisfactorily:
    • Select Thread Tools (on top of your 1st post)
    • Select Mark this thread as Solved

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Instant Comment Box

    Worksheet event code is stored on a worksheet module. To add it to your worksheet, do the following:

    Copy the code
    Select the worksheet in which you the code to run
    Right click on the sheet tab and choose View Code, to open the Visual Basic Editor.
    Where the cursor is flashing, choose Edit | Paste

    Here is the code.
    Private Sub Worksheet_Change(ByVal Target As Range)
    
        If Target.Count > 1 Then Exit Sub
        If Target.Column <> 1 Then Exit Sub
    
        If Target = "6111" Then
            With Target
    
                .ClearComments
                .AddComment
                .Comment.Visible = False
                .Comment.Text Text:="What the HECK!!"
                .Comment.Shape.TextFrame.AutoSize = True
    
            End With
        Else: Target.ClearComments
        End If
    
    End Sub

  4. #4
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: Instant Comment Box

    use this instead of my previous code

    Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    If Target.Value = 6111 Then
        Target.AddComment ("Attention")
    ElseIf Target.Comment.Text = "Attention" Then
        Target.ClearComments
    End If
    End Sub
    Last edited by Kelshaer; 03-07-2012 at 10:27 AM.

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Instant Comment Box

    Quote Originally Posted by Kelshaer View Post
    use this instead of my previous code

    Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    If Target.Value = 6111 Then
        Target.AddComment ("Attention")
    ElseIf Target.Comment.Text = "Attention" Then
        Target.ClearComments
    End If
    End Sub
    What determines Column A ?

  6. #6
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: Instant Comment Box

    DaveExcel: Thanks, I just missed it

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column <> 1 or Target.Count > 1 Then Exit Sub
    On Error Resume Next
    If Target.Value = 6111 Then
        Target.AddComment ("Attention")
    ElseIf Target.Comment.Text = "Attention" Then
        Target.ClearComments
    End If
    End Sub

+ 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