Copy cell contents into cell comment
-
- BronzeLounger
- Posts: 1250
- Joined: 03 Feb 2010, 19:59
- Location: Terneuzen, the Netherlands
Copy cell contents into cell comment
I have a cell with a lot of text. I want to copy that text and add it to a cell-comment. How do I start?
-
- Administrator
- Posts: 12611
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: Copy cell contents into cell comment
To add a comment to a cell you use syntax like
Code: Select all
With Worksheets(1).Range("A1").AddComment
.Visible=True
.Text= "Whatever"
End With
StuartR
-
- BronzeLounger
- Posts: 1250
- Joined: 03 Feb 2010, 19:59
- Location: Terneuzen, the Netherlands
Re: Copy cell contents into cell comment
Thanks, that is probably the part I could figure out. Question is, how do I get the cell text in a variable (it's > 1000 chars!) and then that variable into the comment?
I tried this, the first part works; but get an error when I assign the .TEXT:
I tried this, the first part works; but get an error when I assign the .TEXT:
Code: Select all
t = Range("F3").Text
With ActiveSheet.Range("E3").AddComment
.Visible = True
.Text = t
End With
-
- Administrator
- Posts: 12611
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: Copy cell contents into cell comment
Sorry, that was my error. The correct syntax for that line is
.Text t
not
.Text = t
Try replacing your code with
.Text t
not
.Text = t
Try replacing your code with
Code: Select all
Dim rng As Range
Set rng = ActiveSheet.Range("F3")
With rng.AddComment
.Visible = True
.Text rng.Value
End With
Set rng = Nothing
StuartR
-
- BronzeLounger
- Posts: 1250
- Joined: 03 Feb 2010, 19:59
- Location: Terneuzen, the Netherlands
Re: Copy cell contents into cell comment
OK, works. Thank you