Visualize comments as plain text in other cell

edge37

Board Regular
Joined
Sep 1, 2016
Messages
57
Office Version
  1. 2021
Platform
  1. Windows
Good day, I was wondering is there is a way to visualize a comment of a cell in another cell as plain full text (not as comment as well). I want to input comments on some student's grades and when I click on that cell I want the student see the comments in another cell, just like the representation I made in the pic. Thanks for your help
Screenshot_4.jpg
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
See if this worksheet selection change event code does what you want.

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  If Target.CountLarge = 1 Then
    If Not Target.Comment Is Nothing Then Range("B7").Value = Mid(Target.Comment.Text, InStr(1, Target.Comment.Text, ":") + 1)
  End If
End Sub
 
Upvote 0
See if this worksheet selection change event code does what you want.

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  If Target.CountLarge = 1 Then
    If Not Target.Comment Is Nothing Then Range("B7").Value = Mid(Target.Comment.Text, InStr(1, Target.Comment.Text, ":") + 1)
  End If
End Sub
Thank you Peter, it works when I click the cell with comment, but the comment will stay there even if I click some other cell. My idea is that when this happens, I click other cell with another comment and now the new comment shows, or if I click any other cell without a comment nothing appears in the cell. Maybe an extra VB code would nail it. Thanks anyway for your help.
 
Upvote 0
I see, so if B7:E8 is the range that has the borders around it, you want that range to be dynamic, meaning showing what the active cells comment says--if it has a comment.

Peter's code just needs a couple of else statements

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  If Target.CountLarge = 1 Then
      If Not Target.Comment Is Nothing Then
           Range("B7").Value = Mid(Target.Comment.Text, InStr(1, Target.Comment.Text, ":") + 1)
      Else
           Range("B7").ClearContents
      End If
   Else
          Range("B7").ClearContents
   End If
End Sub


However, I'm not sure why you need to test if the target has an object (If Target.CountLarge = 1), it seems that's just an unnecessary extra step
 
Upvote 0
Peter's code just needs a couple of else statements

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.CountLarge = 1 Then
If Not Target.Comment Is Nothing Then
Range("B7").Value = Mid(Target.Comment.Text, InStr(1, Target.Comment.Text, ":") + 1)
Else
Range("B7").ClearContents
End If
Else
Range("B7").ClearContents
End If
End Sub
I believe that code will error given the OP's set-up where the comment display area appears to be a group of merged cells.

I'm not sure why you need ... (If Target.CountLarge = 1), it seems that's just an unnecessary extra step
That's a fair enough comment. My reasoning was that since the comment would be in a single cell** it seemed reasonable to avoid the rest of the code if we were not dealing with such a scenario.

** However, your comment prompted me to re-consider the code and I guess it might be possible that a comment itself may be in a merged cell area and if so, my previous code would not display it.
@edge37 If it is possible that you have actual comments in merged cells then the code below will also need modification as for now I have still assumed they are in single cells

This would be my revised code.

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  If Target.Comment Is Nothing Then
    Range("B7").Value = ""
  Else
    Range("B7").Value = Mid(Target.Comment.Text, InStr(1, Target.Comment.Text, ":") + 1)
  End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,179
Members
448,871
Latest member
hengshankouniuniu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top