Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 80
Default Clear Comment problem

hello,

I want to get the code below to stop inserting comment when I hit cancel. Any
help?

Thx.

Sub vbutton()
Dim strComments As String
strComments = InputBox("Please Type your comment")

ActiveCell.AddComment
ActiveCell.Comment.Visible = False
ActiveCell.Comment.Text Environ$("USERNAME") & Chr(10) & strComments
If Cancel = True Then
ActiveCell.ClearComments
End If
End Sub

--
Message posted via http://www.officekb.com

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default Clear Comment problem

Sub vbutton()
Dim strComments As String
strComments = InputBox("Please Type your comment","Enter Comment","")
If Len(strComments) 0 Then
ActiveCell.AddComment
ActiveCell.Comment.Visible = False
ActiveCell.Comment.Text Environ$("USERNAME") & Chr(10) & strComments
If Cancel = True Then
ActiveCell.ClearComments
End If
End If
End Sub

The revision to the InputBox statement makes an empty string the default,
the new IF test will test content of strComment and if it is empty, will not
add a comment to the cell.

"saman110 via OfficeKB.com" wrote:

hello,

I want to get the code below to stop inserting comment when I hit cancel. Any
help?

Thx.

Sub vbutton()
Dim strComments As String
strComments = InputBox("Please Type your comment")

ActiveCell.AddComment
ActiveCell.Comment.Visible = False
ActiveCell.Comment.Text Environ$("USERNAME") & Chr(10) & strComments
If Cancel = True Then
ActiveCell.ClearComments
End If
End Sub

--
Message posted via http://www.officekb.com


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 80
Default Clear Comment problem

Thank you. works great.

JLatham wrote:
Sub vbutton()
Dim strComments As String
strComments = InputBox("Please Type your comment","Enter Comment","")
If Len(strComments) 0 Then
ActiveCell.AddComment
ActiveCell.Comment.Visible = False
ActiveCell.Comment.Text Environ$("USERNAME") & Chr(10) & strComments
If Cancel = True Then
ActiveCell.ClearComments
End If
End If
End Sub

The revision to the InputBox statement makes an empty string the default,
the new IF test will test content of strComment and if it is empty, will not
add a comment to the cell.

hello,

[quoted text clipped - 14 lines]
End If
End Sub


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200708/1

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
copy comment content to cell content as data not as comment Lilach Excel Discussion (Misc queries) 2 June 21st 07 12:28 PM
How can I edit a comment w/o first having to select Show Comment Mary Ann Excel Discussion (Misc queries) 1 August 26th 05 12:34 AM
How do I insert a comment when the Insert:Comment menu is greyed? none Excel Discussion (Misc queries) 0 May 19th 05 12:36 AM
Hotkey problem w/ macro to append comment roadkill Excel Discussion (Misc queries) 1 April 6th 05 06:52 PM
a comment plugin & copy paste directly from excel to comment ? fr. RFM Excel Worksheet Functions 0 December 1st 04 11:29 PM


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

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

About Us

"It's about Microsoft Excel"