![]() |
#2
|
|||
|
|||
![]()
below vba code do
I want to not to a cell, I want this to range, or particular a1, f2, h25 cell how? http://www.vbaexpress.com/kb/getarticle.php?kb_id=893 'Code to be placed in the worksheet(s) you want to use this in Option Explicit Public oldRange As Range Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) On Error Resume Next Dim rng As Range Set rng = Target(1, 1) oldRange.Comment.Visible = False With rng If Not .Comment Is Nothing Then If .Comment.Visible = False Then .Comment.Visible = True Else .Comment.Visible = False End If End If End With Set oldRange = Target(1, 1) End Sub Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean) On Error Resume Next Dim cmtText As String Dim inputText As String If Target.Comment Is Nothing Then cmtText = InputBox("Enter info:", "Comment Info") If cmtText = "" Then Exit Sub Target.AddComment Text:=cmtText Target.Comment.Visible = True Target.Comment.Shape.TextFrame.AutoSize = True 'Remove if you want to size it yourself Else If Target.Comment.Text <> "" Then inputText = InputBox("Enter info:", "Comment Info") If inputText = "" Then Exit Sub cmtText = Target.Comment.Text & Chr(10) & inputText Else cmtText = InputBox("Enter info:", "Comment Info") End If Target.ClearComments Target.AddComment Text:=cmtText Target.Comment.Visible = True Target.Comment.Shape.TextFrame.AutoSize = True 'Remove if you want to size it yourself End If Cancel = True 'Remove this if you want to enter text in the cell after you add the comment End Sub. |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to Insert Text Into Cells Having Multiple Lines | revans611 | Excel Programming | 4 | 10-24-2011 10:15 AM |
![]() |
OTPM | Excel | 11 | 05-23-2011 11:18 AM |
![]() |
PSYloco | Excel | 2 | 05-14-2011 03:46 PM |
![]() |
VinceO | Excel | 1 | 05-09-2011 06:38 AM |
![]() |
jrasche2003@yahoo.com | Excel | 2 | 02-09-2007 07:10 AM |