Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop through last cell/row of used range tkraju via OfficeKB.com Excel Discussion (Misc queries) 1 April 4th 09 04:45 PM
loop code on cell range Otto Excel Discussion (Misc queries) 1 July 3rd 08 02:35 PM
Cell names = sheet names Vince Excel Worksheet Functions 9 February 8th 08 03:59 PM
get for loop to go on after blank cell? john_t_h[_12_] Excel Programming 3 January 15th 04 06:35 AM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 08:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"