View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jason Lepack Jason Lepack is offline
external usenet poster
 
Posts: 120
Default For Next loop

Sorry for the confusion. When I get home tonight I'll look at your
situation in a little more detail. However, for now, your names are
not specific to your worksheet, they are specific to your workBOOK.
So, go from there!

Sub Macro1()
Dim wb As Workbook
Dim n As Name
Set wb = ActiveWorkbook
For Each n In wb.Names
Debug.Print n.Name
Next n
End Sub

Cheers,
Jason Lepack

Kevin wrote:
Yes, the name of cell a1 would be switch1port1 and the text inside the cell
would say host1 I will email you a page..

"Jason Lepack" wrote:

Do you mean that you have actually "named" the cell "A1" to
"switch1port1" or is the value of cell "A1" = "switch1port1"?

I think I know what your saying... Could you please give an example of
what your sheet looks like?

You could email me your spreadsheet, but if you do, post here just to
let me know you emailed it.

Cheers,
Jason Lepack

Kevin wrote:
There hundreds of names on each sheet.

Basically each name represents a cell for each port on a switch.
I want to go to have a summary page that will go through each name and add
the text from that cell to the next line on the summary page.

ex, if sheet1 range(a1) has the name switch1port1 and switch1port2, I want
to loop through the names and add the text from each of those cells to a page
called summary. if the text in those 2 cells is Host1 and Host2 then I want
Host1 and Host2 added to the summary page.

I cant just go down the list from each page because the cells on each switch
page are all over the place as I laid it out to look physically like the
switch.

Hope that makes sense....

"Jason Lepack" wrote:

What exactly are you trying to do?

The reason it doesn't go into the loop is because there are no names in
that worksheet.

If you let the group know why you want to do that loop, then the group
can tell you how to do it.

Cheers,
Jason Lepack


Doug Glancy wrote:
Kevin,

Dim Nam as Name
For each Nam in Activesheet.Names
'yak yak yak
Next Nam

hth,

Doug

"Kevin" wrote in message
...
I want to perform certain tasks for each name in the activeworksheet. I'm
not
sure how to write the loop.

For Each Name in Activesheet
blah blah
Next

This doesnt work, what would be the correct syntax?