Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Looping thru spreadsheets in a workbook

This one is a bit complicated and I understand if anyone
wants further clarification

Scenario

In an Excel workbook I have a login sheet which is hidden
in Column A of the login sheet I Have a list of all the
sheets in the workbook. ( say A1 thru A10)

Currently what happens is when the workbook opens I have a
piece of code which activates each individual sheet and
then carrys out some action. then it goes to the next
sheet and so on, this becomes a very lengthy process as
the code can be quite long

What I am looking for is code where it looks at the login
sheet grabs the value in Cell A1 and carry's out the
action then as long as there is a value in column A it
will keep refreshing the sheets, ie it moves to cell A2
passes the sheet name back to the code and continues on.
As soon as it comes across an empty value in Column A (ie
column A11) it stops and exits the code.

If you need further clarification please do not hesitate
to email me


Thanks in Advance

Nigel

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Looping thru spreadsheets in a workbook

Assume the sheetname is Login

Dim cell as Range, rng as Range
dim sh as Worksheet
With worksheets("Login")
set rng = .range(.Cells(1,1),.Cells(1,1).End(xldown))
End with

for each cell in rng
set sh = worksheets(cell.Value)
msgbox sh.name
Next


--
Regards,
Tom Ogilvy

"Nigel Bennett" wrote in message
...
This one is a bit complicated and I understand if anyone
wants further clarification

Scenario

In an Excel workbook I have a login sheet which is hidden
in Column A of the login sheet I Have a list of all the
sheets in the workbook. ( say A1 thru A10)

Currently what happens is when the workbook opens I have a
piece of code which activates each individual sheet and
then carrys out some action. then it goes to the next
sheet and so on, this becomes a very lengthy process as
the code can be quite long

What I am looking for is code where it looks at the login
sheet grabs the value in Cell A1 and carry's out the
action then as long as there is a value in column A it
will keep refreshing the sheets, ie it moves to cell A2
passes the sheet name back to the code and continues on.
As soon as it comes across an empty value in Column A (ie
column A11) it stops and exits the code.

If you need further clarification please do not hesitate
to email me


Thanks in Advance

Nigel



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Looping thru spreadsheets in a workbook

Thank you very much, that worked great, I do have one
other question

I would like to change the color of the active cell to
yellow as it loops thru so the user knows what sheet is
being activated

I tried

cell.Value.ForeColor = 0 ( I just put ) as I was not sure
of the code for yellow)

which doesn't work

any advice

Thanks
-----Original Message-----
Assume the sheetname is Login

Dim cell as Range, rng as Range
dim sh as Worksheet
With worksheets("Login")
set rng = .range(.Cells(1,1),.Cells(1,1).End(xldown))
End with

for each cell in rng
set sh = worksheets(cell.Value)
msgbox sh.name
Next


--
Regards,
Tom Ogilvy

"Nigel Bennett" wrote in message
...
This one is a bit complicated and I understand if anyone
wants further clarification

Scenario

In an Excel workbook I have a login sheet which is

hidden
in Column A of the login sheet I Have a list of all the
sheets in the workbook. ( say A1 thru A10)

Currently what happens is when the workbook opens I

have a
piece of code which activates each individual sheet and
then carrys out some action. then it goes to the next
sheet and so on, this becomes a very lengthy process as
the code can be quite long

What I am looking for is code where it looks at the

login
sheet grabs the value in Cell A1 and carry's out the
action then as long as there is a value in column A it
will keep refreshing the sheets, ie it moves to cell A2
passes the sheet name back to the code and continues on.
As soon as it comes across an empty value in Column A

(ie
column A11) it stops and exits the code.

If you need further clarification please do not hesitate
to email me


Thanks in Advance

Nigel



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Going to a sheet when selecting a cell

On the list I would like also to select one of the cells
and have the focus go directly to the sheet in that cell
name


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Going to a sheet when selecting a cell

You started out by saying

In an Excel workbook I have a login sheet which is hidden


I guess you meant it isn't hidden.

Dim cell as Range, rng as Range
dim sh as Worksheet
With worksheets("Login")
set rng = .range(.Cells(1,1),.Cells(1,1).End(xldown))
End with

for each cell in rng
cell.Activate
cell.Interior.ColorIndex = 6
set sh = worksheets(cell.Value)
msgbox sh.name
Next

--
Regards,
Tom Ogilvy


"Nigel Bennett" wrote in message
...
On the list I would like also to select one of the cells
and have the focus go directly to the sheet in that cell
name




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
Maximunm # of Spreadsheets in any Workbook No Name New Users to Excel 8 May 16th 07 12:23 AM
creating a looping formula between different spreadsheets Jon Buonocore New Users to Excel 0 March 28th 06 04:29 AM
looping a calculation until workbook closes tjb Excel Worksheet Functions 0 April 22nd 05 07:06 PM
macro to browse for workbook, pick up data and looping uriel78 Excel Worksheet Functions 1 March 10th 05 12:37 PM
Looping Through Worksheets In A Workbook Steve[_27_] Excel Programming 3 August 5th 03 03:40 PM


All times are GMT +1. The time now is 12:34 AM.

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"