View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Akash Akash is offline
external usenet poster
 
Posts: 125
Default Converting cell content into comment

Hi still its not working dear.

do i have to add a Button to my sheet.

I dont want the button to be added in my sheet. I want a normar code
for the same.

Pls do help.

Thanks

Akash

On Sep 4, 12:28 pm, Zoltan wrote:
Sorry,
my mistake. Please see the code which works well (this time I tested)

Private Sub CommandButton1_Click()
Dim rng As Range
Dim mycell As Range

Set rng = Range("A1:C5") ' the range you would like to use

For Each mycell In rng
If Not mycell.Find("Leave") Is Nothing Then
mycell.Replace what:="Leave", replacement:="x" 'x is the replacement
string
mycell.AddComment "Leave"
Else
mycell.ClearComments
End If
Next

End Sub

Regards,
Zoltan

"Akash" wrote:
Hi Zoltan,


Thanks for the help but its not working. I am facing error in the
line:


If mycell.Find("Leave") Then


Pls do tell me what should i do in this regard.


Thanks


Akash


On Sep 4, 11:34 am, Zoltan wrote:
Akash,


try this code:


Private Sub CommandButton2_Click()


dim rng as range
dim mycell as range


set rng = range("A1:C5") ' the range you would like to use


for each mycell in rng
if mycell.find ("Leave") then
mycell.Replace what:="Leave", replacement:="x" 'x is the replacement
string
mycell.addcomment "Leave"
end if
Next


End Sub


I hope it helps,
Zoltan


"Akash" wrote:
On Sep 4, 9:41 am, Akash 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


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 that comment to a particular
cell. How can i do that.


thanks in advance


Akash