Re: Adding a variable value to a comment?



How about just plopping that value directly into the comment:

Option Explicit
Sub testme01()
With ActiveCell
If .Comment Is Nothing Then
'do nothing
Else
.Comment.Delete
End If
.AddComment Text:=CStr(.Value + .Offset(0, -3).Value)
.Comment.Visible = True
End With
End Sub

Tom wrote:

How can I add a variable value to a comment?
I want to create a comment that is based on a simple math function.

The comment tag would display the sum of the current cell plus that of one
other.

Here is what I have so far:
-----------------------
dim holdval, commentval
holdval = ActiveCell.Value
ActiveCell.ForumlaR1C1 = "=RC[0]+RC[-3]"
ActiveCell.AddComment
ActiveCell.Comment.Visible = True
commentval = ActiveCell.Value
ActiveCell.Comment.Text = commentval
ActiveCell.Value = holdval
ActiveCell.Select
---------------------------

Line 7 is where I'm getting all the problems. The error I get is "Assignment
to constant is not permitted". I've also tried this line:

ActiveCell.Comment.Text Text:= commentval

in which case I get an application error.

Am I just trying to do something that is impossible or is there another way
to get a variable value into a comment?

Thanks!

--

Dave Peterson
.



Relevant Pages

  • Re: Simple cascading combo boxes
    ... The row source property of the Capability combobox shows the following: ... After deleting the original Sub, I created a new one with Option Explicit at ... cboCapability then you need to requery cboCapability. ...
    (microsoft.public.access.gettingstarted)
  • Re: Drag and Drop File Name from Windows Explorer into Access Form Textbox
    ... I had also added an "Option Explicit" to the top of Dev's module. ... A2000 and above have the AddressOf operator. ... Sub sHook(Hwnd As Long, _ ... dragging and dropping a file/folder name from Windows XP Explorer into ...
    (comp.databases.ms-access)
  • Re: Select one checkbox to Deselect another
    ... Option Explicit ... Dim ObjCollection As Collection ... Private WithEvents pChkBox As MSForms.CheckBox ... Private Sub Class_Initialize ...
    (microsoft.public.excel.programming)
  • Re: Problem with Combo Box
    ... you don't have Option Explicit specified for your module. ... Don't use this form of class module reference; ... Further, if the recordset is ... > Exit Sub ...
    (microsoft.public.access.formscoding)
  • Re: Macro for EACH workbook-->help modify to ONE macro for ALL wor
    ... Sub QuoteCopy_Ben, it looked to me, like it had nothing to do with the ... That's why I put Option Explicit after Sub. ... below the Sub QuoteCopy_Benmacro in the same module? ... different workbooks by clicking a button in the open workbook ...
    (microsoft.public.excel)