Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-04-2012, 05:56 AM
gsrikanth gsrikanth is offline how to gave comments to multiple cells at a time Windows XP how to gave comments to multiple cells at a time Office XP
Competent Performer
how to gave comments to multiple cells at a time
 
Join Date: Dec 2011
Posts: 133
gsrikanth is on a distinguished road
Default cell to range (comments)

below vba code do
  1. Double click on a cell
  2. Write the text to be placed in the comment
  3. Press Enter


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.
Reply With Quote
 



Similar Threads
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
how to gave comments to multiple cells at a time Multiple VLOOKUP's checking multiple Cells OTPM Excel 11 05-23-2011 11:18 AM
how to gave comments to multiple cells at a time Concatenate/merge contents of multiple cells PSYloco Excel 2 05-14-2011 03:46 PM
how to gave comments to multiple cells at a time filling multiple cells whislt using Filter VinceO Excel 1 05-09-2011 06:38 AM
how to gave comments to multiple cells at a time How to get cells to calculate time? jrasche2003@yahoo.com Excel 2 02-09-2007 07:10 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:48 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft