Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with code
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with code
I think the below works, sorry for a false-alarm,,,
Jim "Jim May" wrote in message : 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with code
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with code
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with code
Thanks petersod;
Appreciate your help. Jim " wrote in message : 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Drop Down/List w/Code and Definition, only code entered when selec | Excel Worksheet Functions | |||
Modification in the CODE to HIDE rows and columns that start with ZERO (code given) | Excel Programming | |||
Excel code convert to Access code - Concat & eliminate duplicates | Excel Programming | |||
stubborn Excel crash when editing code with code, one solution | Excel Programming |