Loop for changing cell formatting

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a group of cells that I have renamed cell1,cell2,cell3... and so on up to 30. I would like to take the number from the cell name and put it in a loop until it reaches 30. While it is in the loop, I would like each cell that matches the number to have protection placed on it. Any help would be great. Thanks. Matt
 
Dim rng as Range
Dim i as long
for i = 1 to 30
set rng = Thisworkbook.Names("cell" & i).RefersToRange
rng.locked = True
next

--
Regards,
Tom Ogilvy

Matt said:
I have a group of cells that I have renamed cell1,cell2,cell3... and so on
up to 30. I would like to take the number from the cell name and put it in
a loop until it reaches 30. While it is in the loop, I would like each cell
that matches the number to have protection placed on it. Any help would be
great. Thanks. Matt
 
Back
Top