Results 1 to 5 of 5

InputBox: Cancel/X properties

Threaded View

  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,177

    InputBox: Cancel/X properties

    This macro adds a comment to a cell and some text from an input box. I store the last value entered in the input box via the registry, it is recalled as the default input box value.

    How do I capture the cancel property (Boolean, true or false?) so the ActiveCell.Value remains and comment is not added?

    When a user selects Cancel/X the macro deletes the value in the cell and add's a comment. This overwrites existing data with "" (nothing).

    The VBA help file wasn't very helpful, or, I did not know what to look for.

    Sub AddComment()
    'Special thanks to shg of excelforum.com
    
    Dim x As String
    Dim y As String
    
    x = GetSetting("LastComment", "Variables", "x")
    x = InputBox("Enter text", "Enter Comment", x)
    SaveSetting "LastComment", "Variables", "x", x
    
    With ActiveCell
        If Not .Comment Is Nothing Then .Comment.Delete
            .AddComment.Text Text:="35:" & vbLf & _
                    "Do not delete comment"
            .Value = x
    End With
    'If user selects "Cancel/X" cell value is deleted and comment added?
    End Sub
    Any hints, tips or examples are appreciated.
    Last edited by Rick_Stanich; 10-08-2009 at 04:47 PM.
    Regards

    Rick
    Win10, Office 365

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