Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Add Comment Problem

Cannot get this to work; help would be appreciated. Am trying to have a
comment show whenever someone goes to any cell within range A1:A20. I've put
the following (and all variations I can think of to try) in the module for
the tab that has range A1:A20, as follows:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1:$A$20" Then
With Range("$A$1:$A$20")
.AddComment.Text Text:="Gold is a good thing to have..."
.Comment.Visible = True
.Comment.Shape.TextFrame.AutoSize = True
End With
End If
End Sub

Can someone tell me what I'm doing wrong please?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Add Comment Problem

Maybe...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
dim myCell as Range
dim myRng as range
set myrng = me.range("a1:A20")
if intersect(target,myrng) is nothing then exit sub
for each mycell in intersect(target,myrng).cells
with mycell
.clearcomments 'remove old comment if there is one
.AddComment.Text Text:="Gold is a good thing to have..."
.Comment.Visible = True
.Comment.Shape.TextFrame.AutoSize = True
End With
next mycell
End Sub

By looking at target.address = "$A1:$A20", you actually had to select that whole
range--and nothing more.

And then adding one comment to that whole range would still cause problems.

Paige wrote:

Cannot get this to work; help would be appreciated. Am trying to have a
comment show whenever someone goes to any cell within range A1:A20. I've put
the following (and all variations I can think of to try) in the module for
the tab that has range A1:A20, as follows:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1:$A$20" Then
With Range("$A$1:$A$20")
.AddComment.Text Text:="Gold is a good thing to have..."
.Comment.Visible = True
.Comment.Shape.TextFrame.AutoSize = True
End With
End If
End Sub

Can someone tell me what I'm doing wrong please?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Add Comment Problem

Target.Address = "$A$1:$A$20" is only true when the selection is the entire
range A1:A20; to identify whether any cell in that range is selected you need
to do this:
If Not(Intersect(Target, Range("$A$1:$A$20")) Is Nothing) Then
With Range("$A$1:$A$20")
.AddComment.Text Text:="Gold is a good thing to have..."
.Comment.Visible = True
.Comment.Shape.TextFrame.AutoSize = True
End With
End If
--
- K Dales


"Paige" wrote:

Cannot get this to work; help would be appreciated. Am trying to have a
comment show whenever someone goes to any cell within range A1:A20. I've put
the following (and all variations I can think of to try) in the module for
the tab that has range A1:A20, as follows:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1:$A$20" Then
With Range("$A$1:$A$20")
.AddComment.Text Text:="Gold is a good thing to have..."
.Comment.Visible = True
.Comment.Shape.TextFrame.AutoSize = True
End With
End If
End Sub

Can someone tell me what I'm doing wrong please?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Add Comment Problem

Mucho thanks to both of you - got it working!! Have a great day.....Paige

"Paige" wrote:

Cannot get this to work; help would be appreciated. Am trying to have a
comment show whenever someone goes to any cell within range A1:A20. I've put
the following (and all variations I can think of to try) in the module for
the tab that has range A1:A20, as follows:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1:$A$20" Then
With Range("$A$1:$A$20")
.AddComment.Text Text:="Gold is a good thing to have..."
.Comment.Visible = True
.Comment.Shape.TextFrame.AutoSize = True
End With
End If
End Sub

Can someone tell me what I'm doing wrong please?

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
Problem with printing comment in Excel 2007 Michelle Excel Discussion (Misc queries) 6 October 1st 09 08:49 PM
Edit Comment problem Ajay N Excel Discussion (Misc queries) 1 June 16th 09 09:49 PM
excel 2007 edit comment problem gage Excel Discussion (Misc queries) 3 October 24th 08 01:11 AM
Clear Comment problem saman110 via OfficeKB.com Excel Discussion (Misc queries) 2 August 13th 07 04:31 AM
Hotkey problem w/ macro to append comment roadkill Excel Discussion (Misc queries) 1 April 6th 05 06:52 PM


All times are GMT +1. The time now is 03:34 PM.

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"