try Sub test() Dim rng As Excel.Range Dim v As Excel.Range Set rng = [a1:a10] For Each v In rng write_comment v.Offset(, 1), v Next End Sub Sub write_comment(rngc As Excel.Range, rngt As Excel.Range) If TypeName(rngc.Comment) = "Nothing" Then rngc.AddComment.Text End If rngc.Comment.Text CStr(rngt.Value) End Sub regards r
2011/1/26 Seba <sebastjan.hri...@gmail.com> > Hello, > > I recorded a macro which adds content from certain range of cells to > another range of cells. Each cell serves as a content source for the > target cell comment. > > My problem is this. The source content is added periodically and if I > trigger the macro for the second time, when I add source content to > another source cell, I get this error: > 'Run-time error 1004' > Application defined or object defined error > > I suppose macro should be adapted in a way, that all content is > cleared and added again or something like that... > > Here is the test macro: > > -------------------------------------------------------------------------- > Sub komentar() > ' > ' komentar Makro > ' > > ' > Range("F14").Select > Range("F14").AddComment > Range("F14").Comment.Visible = True > Range("F14").Comment.Text Text:="User:" & Chr(10) & "" > Range("F20").Select > Selection.Copy > Range("F14").Comment.Shape.Select True > Application.CutCopyMode = False > Range("F14").Comment.Text Text:="User:" & Chr(10) & "" > Range("F20").Select > ActiveCell.FormulaR1C1 = "asdasda" > Range("F14").Comment.Shape.Select True > Range("F14").Comment.Text Text:="User:" & Chr(10) & "asdasda" > Range("G21").Select > End Sub > > -------------------------------------------------------------------------------------- > > Could anyone please help? > > regards, > > seba > > -- > > ---------------------------------------------------------------------------------- > Some important links for excel users: > 1. Follow us on TWITTER for tips tricks and links : > http://twitter.com/exceldailytip > 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 > 3. Excel tutorials at http://www.excel-macros.blogspot.com > 4. Learn VBA Macros at http://www.quickvba.blogspot.com > 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com > > To post to this group, send email to excel-macros@googlegroups.com > > <><><><><><><><><><><><><><><><><><><><><><> > Like our page on facebook , Just follow below link > http://www.facebook.com/discussexcel > -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel