Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Comments to a Selection in Excel 97

Status
Not open for further replies.

sirhobbit

Technical User
Aug 24, 2003
4
AU
Hi all,
I am working on a shared spreadsheet where a user who wishes to edit the sheet makes a selection of several cells (all along the same row) and clicks on a button to open a user form. Here they can select options and input text. I have a text box in that user form and I want what ever is written in that box to be made a comment for all the cells highlighted or for only 1 cell at the far left or right of the selection. Any assistance you be appreciated.
 
This should work to add a comment to the leftmost cell in their selection...

Sub comment()
With ActiveCell 'the active cell is the leftmost in any selection [/green]
.AddComment
.comment.Visible = False
.comment.Text Text:="Test" ' insert your own comment from your text box here.[/green]
End With
End Sub
 

With ActiveCell 'the active cell is the leftmost in any selection

Not quite true. If the selection was made by extending to the left, then the rightmost cell will be the activecell. the following is more universal:

with cells(selection.row,selection.column)



Rob
[flowerface]
 
Very true, Rob - this is what comes of typing VB at 8.30 in the morning!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top