Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11
Default Excel VBA and Comment boxes

Hi,

I wrote something that would automatically place the cell content into a
comment box, and replace the cell content with the words "See Comments".

Now, the user wants the comment box to auto-resize....how come I can't get
the comment box selection statement to work?

Thanks!

Private Sub Worksheet_Change(ByVal Target As Range)

Dim strComment As String
Dim strRange As String
strComment = Target.Value
strRange = Target.AddressLocal

'Set Target Row number to avoid this running on changing the header
'Set Target Column to determine column being modified
'Set Target Value so there's no infinite loop from "See Comment" feed

If Target.Row 1 And Target.Column = 2 _
And Range(strRange).Value < "See Comment" _
And Range(strRange).Value < "" Then

Range(strRange).Value = "See Comment"
Range(strRange).Select
Range(strRange).AddComment
Range(strRange).Comment.Visible = False
Range(strRange).Comment.Text Text:=strComment

Range(strRange).Comment.Shape.Select True <- FAIL RIGHT HERE
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.ReadingOrder = xlContext
.Orientation = xlHorizontal
.AutoSize = True
End With

End If

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,805
Default Excel VBA and Comment boxes

Change
Range(strRange).Comment.Visible = False
to
Range(strRange).Comment.Visible = True

Following line will fail (as it is doing now) if comment is not visible...
Range(strRange).Comment.Shape.Select True
--
Always provide your feedback...


"DCPan" wrote:

Hi,

I wrote something that would automatically place the cell content into a
comment box, and replace the cell content with the words "See Comments".

Now, the user wants the comment box to auto-resize....how come I can't get
the comment box selection statement to work?

Thanks!

Private Sub Worksheet_Change(ByVal Target As Range)

Dim strComment As String
Dim strRange As String
strComment = Target.Value
strRange = Target.AddressLocal

'Set Target Row number to avoid this running on changing the header
'Set Target Column to determine column being modified
'Set Target Value so there's no infinite loop from "See Comment" feed

If Target.Row 1 And Target.Column = 2 _
And Range(strRange).Value < "See Comment" _
And Range(strRange).Value < "" Then

Range(strRange).Value = "See Comment"
Range(strRange).Select
Range(strRange).AddComment
Range(strRange).Comment.Visible = False
Range(strRange).Comment.Text Text:=strComment

Range(strRange).Comment.Shape.Select True <- FAIL RIGHT HERE
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.ReadingOrder = xlContext
.Orientation = xlHorizontal
.AutoSize = True
End With

End If

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11
Default Excel VBA and Comment boxes

That did the trick! You rock! (I rated the post too!)

"Sheeloo" wrote:

Change
Range(strRange).Comment.Visible = False
to
Range(strRange).Comment.Visible = True

Following line will fail (as it is doing now) if comment is not visible...
Range(strRange).Comment.Shape.Select True
--
Always provide your feedback...


"DCPan" wrote:

Hi,

I wrote something that would automatically place the cell content into a
comment box, and replace the cell content with the words "See Comments".

Now, the user wants the comment box to auto-resize....how come I can't get
the comment box selection statement to work?

Thanks!

Private Sub Worksheet_Change(ByVal Target As Range)

Dim strComment As String
Dim strRange As String
strComment = Target.Value
strRange = Target.AddressLocal

'Set Target Row number to avoid this running on changing the header
'Set Target Column to determine column being modified
'Set Target Value so there's no infinite loop from "See Comment" feed

If Target.Row 1 And Target.Column = 2 _
And Range(strRange).Value < "See Comment" _
And Range(strRange).Value < "" Then

Range(strRange).Value = "See Comment"
Range(strRange).Select
Range(strRange).AddComment
Range(strRange).Comment.Visible = False
Range(strRange).Comment.Text Text:=strComment

Range(strRange).Comment.Shape.Select True <- FAIL RIGHT HERE
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.ReadingOrder = xlContext
.Orientation = xlHorizontal
.AutoSize = True
End With

End If

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,805
Default Excel VBA and Comment boxes

Thanks for the feeback... it helps everyone.

See http://www.contextures.com/xlcomments03.html for excellent examples for
dealing with comments...

--
Always provide your feedback so that others know whether the solution worked
or problem still persists ...


"DCPan" wrote:

That did the trick! You rock! (I rated the post too!)

"Sheeloo" wrote:

Change
Range(strRange).Comment.Visible = False
to
Range(strRange).Comment.Visible = True

Following line will fail (as it is doing now) if comment is not visible...
Range(strRange).Comment.Shape.Select True
--
Always provide your feedback...


"DCPan" wrote:

Hi,

I wrote something that would automatically place the cell content into a
comment box, and replace the cell content with the words "See Comments".

Now, the user wants the comment box to auto-resize....how come I can't get
the comment box selection statement to work?

Thanks!

Private Sub Worksheet_Change(ByVal Target As Range)

Dim strComment As String
Dim strRange As String
strComment = Target.Value
strRange = Target.AddressLocal

'Set Target Row number to avoid this running on changing the header
'Set Target Column to determine column being modified
'Set Target Value so there's no infinite loop from "See Comment" feed

If Target.Row 1 And Target.Column = 2 _
And Range(strRange).Value < "See Comment" _
And Range(strRange).Value < "" Then

Range(strRange).Value = "See Comment"
Range(strRange).Select
Range(strRange).AddComment
Range(strRange).Comment.Visible = False
Range(strRange).Comment.Text Text:=strComment

Range(strRange).Comment.Shape.Select True <- FAIL RIGHT HERE
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.ReadingOrder = xlContext
.Orientation = xlHorizontal
.AutoSize = True
End With

End If

End Sub

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
Excel spreadsheet comment boxes keep shrinking smaller than text. TM Excel Worksheet Functions 5 January 4th 08 06:19 AM
Excel Comment boxes Ruby Excel Discussion (Misc queries) 5 October 13th 06 11:00 PM
stablize the Excel comment boxes (size and location) Symantec-Maria Excel Discussion (Misc queries) 1 September 1st 06 12:49 AM
In excel spreadsheet my comment boxes change sizes randomly why? Scully Excel Worksheet Functions 0 November 11th 05 08:46 PM
How do I change the default font for comment boxes in Excel cljforbes Excel Discussion (Misc queries) 2 July 19th 05 12:29 PM


All times are GMT +1. The time now is 04:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"