#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15
Default Formulas as comments

I had a great add in for Excel 2000 & 2003 that I could click on a cell and
press CTRL+SHIFT+A and the formula from the cell would get put into the
comment for the cell, and the comment box would remain visible even when
another cell was highlighted.

Unfortunately the same add in does not work in 2007. As I have worksheets
with dozens of formulas it is not convenient to manually cut & paste the
formulas in.

I am looking for a macro, add in, etc that would allow me to do the
equivalent.

Thank you in advance!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 136
Default Formulas as comments

If your goal is visible formulas, don't bother
Press CRTL + ~ (tilde) to display formulas

"Jeff M" wrote:

I had a great add in for Excel 2000 & 2003 that I could click on a cell and
press CTRL+SHIFT+A and the formula from the cell would get put into the
comment for the cell, and the comment box would remain visible even when
another cell was highlighted.

Unfortunately the same add in does not work in 2007. As I have worksheets
with dozens of formulas it is not convenient to manually cut & paste the
formulas in.

I am looking for a macro, add in, etc that would allow me to do the
equivalent.

Thank you in advance!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15
Default Formulas as comments

Tevuna:
CTRL+~ does not help. I need to take excerpt from my workbook and print them
out (including the comments) so that people can understand both the numbers
and the formulas that back them up. What I really need the formulas in the
comments fields.

I make extensive use of named fields so that the formulas make sense visually.

"Tevuna" wrote:

If your goal is visible formulas, don't bother
Press CRTL + ~ (tilde) to display formulas

"Jeff M" wrote:

I had a great add in for Excel 2000 & 2003 that I could click on a cell and
press CTRL+SHIFT+A and the formula from the cell would get put into the
comment for the cell, and the comment box would remain visible even when
another cell was highlighted.

Unfortunately the same add in does not work in 2007. As I have worksheets
with dozens of formulas it is not convenient to manually cut & paste the
formulas in.

I am looking for a macro, add in, etc that would allow me to do the
equivalent.

Thank you in advance!

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Formulas as comments

I'm surprised that your existing addin didn't work with xl2007. Are you sure
you enabled macros when you opened that addin?

But this may work ok for you:

Option Explicit
Sub PutFormulasInComments()
Dim myCell As Range
Dim myStartingRng As Range
Dim myRngToFix As Range
Dim lArea As Double

Set myStartingRng = ActiveSheet.UsedRange
'or
'Set myStartingRng = Selection

Set myRngToFix = Nothing
On Error Resume Next
Set myRngToFix = Intersect(myStartingRng, _
myStartingRng.Cells.SpecialCells(xlCellTypeFormula s))
On Error GoTo 0

If myRngToFix Is Nothing Then
MsgBox "No formulas in Selection"
Exit Sub
End If

myRngToFix.ClearComments

For Each myCell In myRngToFix.Cells
myCell.AddComment Text:=GetFormula(myCell)
With myCell.Comment
.Visible = True 'I'd use False
.Shape.TextFrame.AutoSize = True
If .Shape.Width 300 Then
lArea = .Shape.Width * .Shape.Height
.Shape.Width = 200
.Shape.Height = (lArea / 200) * 1.2
End If
End With
Next myCell

End Sub
Function GetFormula(Rng As Range)
Dim myFormula As String
GetFormula = ""
With Rng.Cells(1)
If .HasFormula Then
If Application.ReferenceStyle = xlA1 Then
myFormula = .Formula
Else
myFormula = .FormulaR1C1
End If
If .HasArray Then
GetFormula = "{=" & Mid(myFormula, 2, Len(myFormula)) & "}"
Else
GetFormula = myFormula
End If
End If
End With
End Function

There are two lines that you may want to review:

Set myStartingRng = ActiveSheet.UsedRange
'or
'Set myStartingRng = Selection

If you really want all the cells on the worksheet processed, then use the top
"Set" line. On the other hand, if you find that you like to select a particular
cell, then just process those cells, you could use the second formula.

In fact, if you select all the cells first, you could always use the second
line.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


Jeff M wrote:

I had a great add in for Excel 2000 & 2003 that I could click on a cell and
press CTRL+SHIFT+A and the formula from the cell would get put into the
comment for the cell, and the comment box would remain visible even when
another cell was highlighted.

Unfortunately the same add in does not work in 2007. As I have worksheets
with dozens of formulas it is not convenient to manually cut & paste the
formulas in.

I am looking for a macro, add in, etc that would allow me to do the
equivalent.

Thank you in advance!


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CELLS NOT CALC FORMULAS - VALUES STAY SME FORMULAS CORRECT?? HELP Sherberg Excel Worksheet Functions 4 September 11th 07 01:34 AM
Having comments copied when using formulas Corkey Excel Worksheet Functions 4 August 8th 07 06:38 PM
in excel useing comments how do you add clip art to comments? dhouse New Users to Excel 2 July 18th 07 08:14 AM
formulas in comments in excel u9946675 Excel Discussion (Misc queries) 0 October 26th 06 11:07 AM
Comments Only [email protected] Excel Discussion (Misc queries) 6 May 8th 06 10:07 PM


All times are GMT +1. The time now is 10:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"