View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Write-back formulas in comment boxes into underlying cells

Many thanks, Tom !

Runs great, but I need a small tweak in Sub Cell_Add_Formula()
which currently writes the phrase "No Formula" into the underlying cell

The need was:
... And for cells with "No Formula" written
into their comment boxes (if any) -to take no action.


And thanks for this too <g ..
Here is a little cleaner version of the great routines.

....
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"Tom Ogilvy" wrote in message
...

Sub Cell_Add_Formula()
'// = = = = = = = = = = = = = =
'// Within a selection...
'// Adds the Cells Formula to the Cells Comoment
'// If no Formula, adds the text..."No Formula"
'// = = = = = = = = = = = = = =

'//
Dim Cell As Range
Dim sStr as String
Const Msg As String = "No Formula"
'//
If TypeName(Selection) < "Range" Then Exit Sub

For Each Cell In Selection.Cells
With Cell
sStr = .NoteText
If sStr = "" Then
.Formula = Msg
Else
.Formula = .NoteText
End If
End With
Next Cell
End Sub


Here is a little cleaner version of the great routines.

Sub Comment_Add_Formula()
'// = = = = = = = = = = = = = =
'// Within a selection...
'// Adds the Cells Formula to the Cells Comoment
'// If no Formula, adds the text..."No Formula"
'// = = = = = = = = = = = = = =

'//
Dim Cell As Range
Const Msg As String = "No Formula"
'//
If TypeName(Selection) < "Range" Then Exit Sub

For Each Cell In Selection.Cells
With Cell
If .HasFormula Then
.NoteText Text:=.Formula
Else
.NoteText Text:=Msg
End If
.Comment.Shape.TextFrame.AutoSize = True
.Comment.Visible = False
End With
Next Cell
End Sub

--
Regards,
Tom Ogilvy