View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Boris[_2_] Boris[_2_] is offline
external usenet poster
 
Posts: 11
Default Converting cell content into comment

On Tue, 04 Sep 2007 05:36:21 -0000, Akash Maheshwari wrote:

Hi,

I have a sheet in which Leave is mentioned many times in different
cell. I want to have a macro through which i can replace the word
Leave and put a Comment with Leave in the cell How can i do that.

thanks in advance

Akash


Akash,

try with this code:
---
Sub DoComment()
Dim R As Range, rF As Range, cFirst As String

Set R = ActiveSheet.UsedRange.Find("Leave", _
LookIn:=xlValues, _
LookAt:=xlPart, _
MatchCase:=False)
If Not R Is Nothing Then
cFirst = R.Address
Do
R.AddComment "Leave in cell"
Set R = ActiveSheet.UsedRange.FindNext(R)
Loop Until R Is Nothing Or R.Address = cFirst
End If
End Sub
---

HTH,
B.