Text/Value from Cell to Comment in another Cell

Faygin

New Member
Joined
May 12, 2020
Messages
23
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I have a range of information in range AE2:AE300.
That i would like to input as comments in Cell T2:T300.

Information in AE2 goes to T2, AE3 to T3, AE4 to T4 and so on.

Its important that nothing else gets changed or formatted in the "Target Cell", it should just add a comment, where there is no comment.

I have a beginning, searched this forum and the internet but i cant find a proper way to do it.
All help and feedback appreciated!

VBA Code:
'Creates variables
Dim ws As Worksheet
Dim GoalCell As Range 'This range is where the comments are going
Dim GetInfo As Range  'This range is where i get the text/values that would be the comment

'Set variables
Set ws = ActiveSheet
Set GoalCell = ws.Range("T2:T300")

'Clear comments from worksheet
GoalCell.ClearComments
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi Faygin,

your code will add the contents from AE to all cells in T as it deletes any existing comment. What about

VBA Code:
Public Sub MrE_1227401_170130B()
' https://www.mrexcel.com/board/threads/text-value-from-cell-to-comment-in-another-cell.1227401/

'code works on the ActiveSheet in Excel
  Dim rngCell As Range

  For Each rngCell In ActiveSheet.Range("T2:T300")
    If rngCell.Comment Is Nothing Then
      With rngCell
        .AddComment
'        .Comment.Visible = True
        .Comment.Text Text:=CStr(ActiveSheet.Cells(rngCell.Row, "AE").Value)
        End With
    End If
  Next rngCell

End Sub

Ciao,
Holger
 
Upvote 0
Solution
Hi Faygin,

your code will add the contents from AE to all cells in T as it deletes any existing comment. What about

VBA Code:
Public Sub MrE_1227401_170130B()
' https://www.mrexcel.com/board/threads/text-value-from-cell-to-comment-in-another-cell.1227401/

'code works on the ActiveSheet in Excel
  Dim rngCell As Range

  For Each rngCell In ActiveSheet.Range("T2:T300")
    If rngCell.Comment Is Nothing Then
      With rngCell
        .AddComment
'        .Comment.Visible = True
        .Comment.Text Text:=CStr(ActiveSheet.Cells(rngCell.Row, "AE").Value)
        End With
    End If
  Next rngCell

End Sub

Ciao,
Holger

Thank you Holger! Great Job, you made my day!
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,141
Members
453,021
Latest member
Justyna P

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