PDA

View Full Version : Solved: Automatic addition of comments to entire column



skandi
08-19-2009, 09:05 AM
Hello all,
i am trying to add empty comments to each of the cells in a column which is of unknown size (i.e. # of utilized cells is unknown... ) this is the code I came up with but its giving me a error 1004: Application-defined or object-defined error

Sub auto_comment()

dim w as Integer
dim Lastrow as Integer
lastrow = cells(Rows.Count, "E").End(xlUp).Row

For w = 7 to Lastrow
Range("E" & w).Select
Range("E" & w).Addcomment ("")
Range("E" & w).Comment.Visible = False
Next

End Sub

If anyone can, please let me know what is causing that error ..
I also tried using a definitive cell like E143 and it put in a comment there.. but for some reason it isn't doing the same when it has to use variables.

any help will be appreciated! THANKS

Bob Phillips
08-19-2009, 09:25 AM
Dim w As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "E").End(xlUp).Row

For w = 7 To Lastrow
Range("E" & w).AddComment ""
Range("E" & w).Comment.Visible = False
Next

skandi
08-19-2009, 09:33 AM
Hey xld
Thanks for the reply, but it still gives me the error..
you basically changed the variable types to long and got rid of selecting each individual cell ..
thats what I did and it doesn't seem to help.;..

skandi
08-19-2009, 09:37 AM
Ok I figured it out..
it was just the fact that some of them had comments and I was trying to put another comment on top of it without removing the first one ..
so there was the problem...