Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Newby Needs minor tweak on this VBA Macro code for Excel

bgeier did a lot to this code, it works perfectly now except for that the
comments don't add to an existing comment, they seem to be overwriting the
existing comment. Please help, this code will be used in a major application
for my company but cannot be used if I cannot get it to function. PLEASE
HELP!

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

strDate = "ddmmmyy hh:mm"
Username = application.Username
Set cmt = ActiveCell.Comment
lName = 0

If cmt Is Nothing Then
Set cmt = ActiveCell.AddComment
With cmt
..Text (Username & " " & Format(Now, strDate) & Chr(10))
..Shape.TextFrame.Characters(1, Len(Username)).Font.Bold = True
End With
Else
Set cmt = ActiveCell.Comment
With cmt
..Shape.TextFrame.Characters(1, Len(cmt.Text)).Font.Bold = False
..Text ("")
..Text (Username)
..Shape.TextFrame.Characters(1, Len(Username)).Font.Bold = True
..Text (cmt.Text & " " & Chr(10) & Format(Now, strDate))
..Shape.TextFrame.Characters(Len(Username) + 1, Len(strDate) + 2).Font.Bold =
False
End With
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Newby Needs minor tweak on this VBA Macro code for Excel

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

Sub KeyCellsChanged()
Dim strDate As String
Dim cmt As Excel.Comment
Dim Username As String
Dim lngLen As Long

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

If cmt Is Nothing Then
Set cmt = ActiveCell.AddComment
With cmt
.Text (Username & " " & Format(Now, strDate) & Chr(10))
.Shape.TextFrame.Characters(1, Len(Username)).Font.Bold = True
End With
Else
With cmt
lngLen = Len(.Text)
.Shape.TextFrame.Characters(1, lngLen).Font.Bold = False
.Text Username, lngLen + 1
.Shape.TextFrame.Characters(lngLen + 1, 999).Font.Bold = True
lngLen = Len(.Text) + 1
.Text " " & Chr(10) & Format(Now, strDate) & Chr(10), lngLen
.Shape.TextFrame.Characters(lngLen, 999).Font.Bold = False
End With
End If
End Sub
'-------------



"zulfer7"
wrote in message
bgeier did a lot to this code, it works perfectly now except for that the
comments don't add to an existing comment, they seem to be overwriting the
existing comment. Please help, this code will be used in a major application
for my company but cannot be used if I cannot get it to function. PLEASE
HELP!

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

strDate = "ddmmmyy hh:mm"
Username = application.Username
Set cmt = ActiveCell.Comment
lName = 0

If cmt Is Nothing Then
Set cmt = ActiveCell.AddComment
With cmt
..Text (Username & " " & Format(Now, strDate) & Chr(10))
..Shape.TextFrame.Characters(1, Len(Username)).Font.Bold = True
End With
Else
Set cmt = ActiveCell.Comment
With cmt
..Shape.TextFrame.Characters(1, Len(cmt.Text)).Font.Bold = False
..Text ("")
..Text (Username)
..Shape.TextFrame.Characters(1, Len(Username)).Font.Bold = True
..Text (cmt.Text & " " & Chr(10) & Format(Now, strDate))
..Shape.TextFrame.Characters(Len(Username) + 1, Len(strDate) + 2).Font.Bold =
False
End With
End If
End Sub
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
Need someone to help tweak a code JB Excel Discussion (Misc queries) 13 January 17th 08 03:04 PM
Can someone please tweak my Macro? Wibs Excel Discussion (Misc queries) 3 December 15th 05 05:10 PM
excel code tweak for outlook - confusing periro16[_2_] Excel Programming 5 August 18th 05 10:29 AM
Macro Code minor alteration please. RPTZ New Users to Excel 6 July 10th 05 05:47 AM
Need final code tweak Phil Hageman Excel Programming 12 August 16th 03 08:53 PM


All times are GMT +1. The time now is 09:10 AM.

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

About Us

"It's about Microsoft Excel"