Copy this programming code below to paste into the Formula Comment macro described during my presentation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
'Declare rng variable as Range Dim rng As Range 'Instruct Excel to skip over errors in code On Error Resume Next 'Loop through each range within the cells selected For Each rng In Selection 'Capture the formula for the current cell strFormula = rng.Formula 'If cell is not blank then... If strFormula <> "" Then 'Erase existing cell note (Office 365 ) or comment (Excel 2019 and earlier) rng.ClearComments 'Add note (or comment) to cell rng.AddComment 'Set the text of the note (or comment) to be the formula rng.Comment.Text strFormula 'Change the font size of the note (or comment) text to be 14 rng.Comment.Shape.TextFrame.Characters.Font.Size=14 'Set the note (or comment) to be visible rng.Comment.Visible = True End If 'Loop through to next cell in selection Next 'Turn off error-handling so that additional errors stop the code from running On Error GoTo 0 |