the last part in the title of my request here ("WHEN YOU CLICK ON A CELL") is what I am really after...
CURRENTLY I have code in my worksheet that when a commandbutton is clicked, it takes all the text within a RANGE OF CELLS ( which is: Range(Cells(370, 9), Cells(rCol, 10)) ) and puts them into comments for all of them... the problem doing it this way is its takes awhile (maybe 8-10 seconds... maybe more) for all of the comments to load. But I dont really need or want ALL of the comments, it would be much more efficient and easier to have the user click on a certain cell (within the same range shown in the code below, preferably) and THEN only copy the text from that one cell that is clicked into a comment... not ALL of the cells within the range.
my code:
screenshot of how it looks after the commandbutton is selected and the text within the range of cells are loaded into comments.
Currently when I run the cursor over the cell it shows the comment as shown... that is really what I would like it to do without having to hit a commandbutton in order to load all of the comments. I just would like it to load the comment for that cell when it is clicked on ... (I'm not even sure if this is possible, tho.)
CURRENTLY I have code in my worksheet that when a commandbutton is clicked, it takes all the text within a RANGE OF CELLS ( which is: Range(Cells(370, 9), Cells(rCol, 10)) ) and puts them into comments for all of them... the problem doing it this way is its takes awhile (maybe 8-10 seconds... maybe more) for all of the comments to load. But I dont really need or want ALL of the comments, it would be much more efficient and easier to have the user click on a certain cell (within the same range shown in the code below, preferably) and THEN only copy the text from that one cell that is clicked into a comment... not ALL of the cells within the range.
my code:
Code:
Private Sub cmdShowComment_Click()
' commandbutton for SHOWING comments from the PROBLEM and ACTION columns
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Dim ws As Worksheet
Dim iCell As Range
Dim rCol As Long
rCol = ActiveSheet.UsedRange.Rows.Count
Dim lArea As Long
Dim MyComments As Comment
For Each ws In ActiveWorkbook.Worksheets
[COLOR=#008000]' THE CODE TAKES THE STRING FROM EACH CELL WITHIN A RANGE OF CELLS AND INSERTS EACH ONE INTO A COMMENT FOR THAT RESPECTIVE CELL.[/COLOR]
For Each iCell In Range(Cells(370, 9), Cells(rCol, 10))
With iCell
If CStr(.Value) <> "" Then
.ClearComments
.AddComment
.Comment.Visible = False
.Comment.Text Text:=CStr(.Value)
.Comment.Shape.TextFrame.Characters.Font.ColorIndex = 5
.Comment.Shape.TextFrame.Characters.Font.Size = 11
.Comment.Shape.TextFrame.Characters.Font.Name = "Lucida Fax"
.Comment.Shape.TextFrame.AutoSize = True
End If
[COLOR=#008000]' THIS CODE RESIZES THE COMMENT BOX SO ITS NOT TOO WIDE WHERE THE USER CANNOT SEE ALL OF THE COMMENTS.[/COLOR]
lArea = .Comment.Shape.Width * .Comment.Shape.Height
If .Comment.Shape.Width > 262 Then
.Comment.Shape.Width = 262
.Comment.Shape.Height = (lArea / 250) * 1.3
End If
End With
Next
Next
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub
screenshot of how it looks after the commandbutton is selected and the text within the range of cells are loaded into comments.
Currently when I run the cursor over the cell it shows the comment as shown... that is really what I would like it to do without having to hit a commandbutton in order to load all of the comments. I just would like it to load the comment for that cell when it is clicked on ... (I'm not even sure if this is possible, tho.)
Last edited: