ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop for changing cell formatting (https://www.excelbanter.com/excel-programming/288017-loop-changing-cell-formatting.html)

matt

Loop for changing cell formatting
 
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

Tom Ogilvy

Loop for changing cell formatting
 
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" wrote in message
...
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




All times are GMT +1. The time now is 10:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com