Can I auto populate Comments in sequence over different sheets ?

N

NickTheBatMan

Anyone out there clever enough to tell me how to sequentially populate
the comments field in cells... the problem I can see is that the cells
are in a grid of A5-10 through to i5 to 10, I want them populating
a5,a6,a7,a8,a9,a10,b5,b6 etc and when I get to i10 I want the sequence
to carry over to the next sheet...

Don't want much do I ;)

TIA

Nick

Sorry if this appears twice, posted via Google Groups and it's not
appeared yet...
 
D

Dave Peterson

Option Explicit
sub Testme()

Dim cCtr as long
dim myCell as range
dim myCol as range
dim myArea as range
dim myRng as range

dim myAddr as string
dim wks as worksheet

myaddr = "a5:I10"
cctr = 0
for each wks in activeworkbook.worksheets
Set myrng = wks.range(myaddr)
for each myarea in myrng.areas
for each myCol in myarea.columns
for each mycell in mycol.cells
cctr = cctr + 1
if mycell.comment is nothing then
'do nothing
else
mycell.comment.delete
end if
mycell.addcomment text:=format(cctr,"0000")
next mycell
next mycol
next myarea
next wks

End sub

I have no idea what you really want in your comments, so I just plopped in a
sequence of numbers--while deleting the existing comments!
 
N

NickTheBatMan

Option Explicit
sub Testme()

Dim cCtr as long
dim myCell as range
dim myCol as range
dim myArea as range
dim myRng as range

dim myAddr as string
dim wks as worksheet

myaddr = "a5:I10"
cctr = 0
for each wks in activeworkbook.worksheets
  Set myrng = wks.range(myaddr)
  for each myarea in myrng.areas
    for each myCol in myarea.columns
       for each mycell in mycol.cells
          cctr = cctr + 1
          if mycell.comment is nothing then
             'do nothing
          else
             mycell.comment.delete
          end if
          mycell.addcomment text:=format(cctr,"0000")
       next mycell
    next mycol
  next myarea
next wks

End sub      

I have no idea what you really want in your comments, so I just plopped ina
sequence of numbers--while deleting the existing comments!







--

Dave Peterson- Hide quoted text -

- Show quoted text -

Excellent Dave, that works :)
Many thanks :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top