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 |
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 |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 03:11 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com