Thread: Help with code
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Help with code

The user could have selected multiple cells (and even multiple areas).

..cells(1) just uses the first sell of their selection.

Jim May wrote:

What does the .Cells(1) do on the end of:

Set MyCell = _
Application.InputBox("What Cell do you want to paste comment in?", _
Type:=8).Cells(1)

TIA,
Jim

" wrote in message
:

I think I'd let the user point at the cell with the mouse. It makes it a bit
easier on you--since you don't have to validate that the user actually entered
an address.

Option Explicit
Sub TransferComment2()
Dim MyCell As Range

Set MyCell = Nothing
On Error Resume Next
Set MyCell = _
Application.InputBox("What Cell do you want to paste comment in?", _
Type:=8).Cells(1)
On Error GoTo 0

If MyCell Is Nothing Then
Exit Sub 'user hit cancel
End If

If MyCell.Comment Is Nothing Then
'do nothing
Else
MyCell.Comment.Delete
End If

With ActiveCell
MyCell.AddComment .Text
.ClearContents
End With

End Sub


Jim May wrote:

I'm trying to "transfer" info typed into a cell (activecell) into a the
comments box of another cell - but can't get it working...

Sub TransferComment()
Dim MyCell As String
Dim CSource As String
CSource = ActiveCell.Value
MyCell = Application.InputBox("What Cell do you want to paste
comment in?")
Range(MyCell).AddComment CSource
ActiveCell.ClearContents
End Sub


--

Dave Peterson


--

Dave Peterson