#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default VBA Code has bug

I have this code in VBA in an Excel Spreadsheet but it has a bug. I cannot
tell if this happens all the time but this code seems to copy the complete
contents of the comment at times when it is only intended to add to the
comment. Any help please!!

Example (1st line of code)
Excel User 05/01/2006

Example (When want to add to the code at a later date)
Excel User 05/01/2006
Excel User 05/01/2006 (This line is repeated)
New User 05/02/2006

Example (When want to add yet another comment later)
Excel User 05/01/2006
Excel User 05/01/2006 (This line is repeated)
New User 05/02/2006
Excel User 05/01/2006 (This line is repeated)
Excel User 05/01/2006 (This line is repeated)
New User 05/02/2006 (This line is repeated)
Another User 05/03/2006

Sub KeyCellsChanged()
Dim strDate As String
Dim cmt As Comment
Dim Username As String


strDate = "ddmmmyy hh:mm"
Username = Application.Username
Set cmt = ActiveCell.Comment

If cmt Is Nothing Then
Set cmt = ActiveCell.AddComment
cmt.Text Text:=Username & Format(Now, strDate) & Chr(10)

Else
cmt.Text Text:=cmt.Text & Chr(10) _
& Username & Format(Now, strDate) & Chr(10)

End If
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
code not unique find latest date Barbara Wiseman Excel Discussion (Misc queries) 3 December 11th 05 08:50 AM
VLOOKUP for Zip Code Ranges JerseyJR Excel Worksheet Functions 2 September 6th 05 06:37 PM
Conform a total to a list of results? xmaveric Excel Discussion (Misc queries) 1 August 21st 05 07:22 PM
Macro for changing text to Proper Case JPriest Excel Worksheet Functions 3 August 8th 05 09:31 PM
close form code tkaplan Excel Discussion (Misc queries) 1 June 3rd 05 10:49 PM


All times are GMT +1. The time now is 02:11 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"