Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop using cell names
I have a group of cells that I have renamed. They are cell1,cell2,cell3 and so on up to 30. Is it possible to take the cell names and extract the number in the cell name so that I can use the number in a loop. I would like to protect these cells as the loop progresses. Thanks.
|
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop using cell names
Matt,
This may help For i = 1 To 3 Debug.Print Range("cell" & i).Value Next i -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Matt" wrote in message ... I have a group of cells that I have renamed. They are cell1,cell2,cell3 and so on up to 30. Is it possible to take the cell names and extract the number in the cell name so that I can use the number in a loop. I would like to protect these cells as the loop progresses. Thanks. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop using cell names
Matt,
Sub TestMe() Dim x As Integer For x = 1 To 30 Range("cell" & x).Locked = True Next x End Sub John "Matt" wrote in message ... I have a group of cells that I have renamed. They are cell1,cell2,cell3 and so on up to 30. Is it possible to take the cell names and extract the number in the cell name so that I can use the number in a loop. I would like to protect these cells as the loop progresses. Thanks. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Loop using cell names
Matt
this example demonstrates how to loop around the cells: Sub LoopRoundCellNames() Dim i As Long For i = 1 To 30 On Error GoTo CellExit MsgBox Range("Cell" & i).Name.Name & _ " " & _ Range("Cell" & i).Address Next 'i CellExit: End Sub What do you mean by "protect the cells"? The cells will be protected (locked) by default but you need to protect the sheet for this to have any effect. Regards Trevor "Matt" wrote in message ... I have a group of cells that I have renamed. They are cell1,cell2,cell3 and so on up to 30. Is it possible to take the cell names and extract the number in the cell name so that I can use the number in a loop. I would like to protect these cells as the loop progresses. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Loop through last cell/row of used range | Excel Discussion (Misc queries) | |||
loop code on cell range | Excel Discussion (Misc queries) | |||
Cell names = sheet names | Excel Worksheet Functions | |||
get for loop to go on after blank cell? | Excel Programming | |||
HELP!!!! Can't stop a loop (NOT an infinite loop) | Excel Programming |