MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Apr 4th, 2002, 06:55 AM   #1
Ian Mac
MrExcel MVP
 
Join Date: Feb 2002
Location: Newcastle, UK
Posts: 1,174
Default

All,

Is there a way of countins the number of sheets that have a certain name on a assigning a Page (Sheet) number to a particular cell on each.

i.e. I have 12 sheets (current) they are all called AgentA Mon, AgentB Mon, AgentC Mon etc. (the AgentA,b,c are real names of people). This is repeated for each day of the week.
What I'd like is for Excel to count the number of sheets and on AgentA put A1= "page 1" B1= "of 12".
the cells don't actually NEED the 'page' or 'of' in them.

I'd like this to be done viewing the sheets left to right in the workbook.

Also, if it's any help every day had the SAME people and ALWAY the same order.

Anyone??
__________________
"Have a good time......all the time"
Ian Mac
Ian Mac is offline   Reply With Quote
Old Apr 4th, 2002, 08:24 AM   #2
codger
 
Join Date: Apr 2002
Posts: 23
Default

Quote:
On 2002-04-04 01:55, Ian Mac wrote:
All,

Is there a way of countins the number of sheets that have a certain name on a assigning a Page (Sheet) number to a particular cell on each.

i.e. I have 12 sheets (current) they are all called AgentA Mon, AgentB Mon, AgentC Mon etc. (the AgentA,b,c are real names of people). This is repeated for each day of the week.
What I'd like is for Excel to count the number of sheets and on AgentA put A1= "page 1" B1= "of 12".
the cells don't actually NEED the 'page' or 'of' in them.

[..]
Bit fogged here: do you mean that if you have 5x3=15 tabs with all combinations of 'AgentA' thru 'C' and Mon thru FRi, putting 'Wed' in a cell would cause a formula to return 3 (for each of the 3 people)?
codger is offline   Reply With Quote
Old Apr 4th, 2002, 09:13 AM   #3
Ian Mac
MrExcel MVP
 
Join Date: Feb 2002
Location: Newcastle, UK
Posts: 1,174
Default

Quote:
On 2002-04-04 03:24, codger wrote:
Quote:
On 2002-04-04 01:55, Ian Mac wrote:
All,

Is there a way of counting the number of sheets that have a certain name on a assigning a Page (Sheet) number to a particular cell on each.

i.e. I have 12 sheets (current) they are all called AgentA Mon, AgentB Mon, AgentC Mon etc. (the AgentA,b,c are real names of people). This is repeated for each day of the week.
What I'd like is for Excel to count the number of sheets and on AgentA put A1= "page 1" B1= "of 12".
the cells don't actually NEED the 'page' or 'of' in them.

[..]
Bit fogged here: do you mean that if you have 5x3=15 tabs with all combinations of 'AgentA' thru 'C' and Mon thru FRi, putting 'Wed' in a cell would cause a formula to return 3 (for each of the 3 people)?
I don't think a formula will do this. If we take Tues - Fri out of the equation and start with just Mon.

If I had Sheets Called:

{"A Mon";"F Mon";"G Mon";"Z Mon";"H Mon"}

AND a summary sheet called: Summary Mon

And they were laid out in the book LEFT to RIGHT where tabs are concerned:

{"Summary Mon";"A Mon";"F Mon";"G Mon";"Z Mon";"H Mon"}.

I'd like some code that would place:

{"Page",1,"of",6} on the Summary Sheet
{"Page",2,"of",6} on sheet "A Mon"
{"Page",3,"of",6} on sheet "F Mon" etc until
{"Page",6,"of",6} on sheet "G Mon"

BUT if I add a Sheet, say "D Mon" I'd like the Summary to read

{"Page",1,"of",7} automatically

Note: the sheets to be added will ALWAYS be between the Second and Last sheets so they will part of the formulas on the summary.

I hope this is a little clearer

Help would be greatfully received.

Many thanks
__________________
"Have a good time......all the time"
Ian Mac
Ian Mac is offline   Reply With Quote
Old Apr 4th, 2002, 09:40 AM   #4
codger
 
Join Date: Apr 2002
Posts: 23
Default

OK, undeterred, I'm going to have a go at a formula based solution. I hope that,

Quote:
[..]
I'd like some code that would place:

{"Page",1,"of",6} on the Summary Sheet
{"Page",2,"of",6} on sheet "A Mon"
{"Page",3,"of",6} on sheet "F Mon" etc until
{"Page",6,"of",6} on sheet "G Mon"

[..]
The last bit should be 'H Mon' - the order the tabs are in the workbook.

1) Create a name, say, Get.WorkBooks.1 that refers to =GET.WORKBOOK(1)
2) Create another name, say, Get.Sheets that refers to =REPLACE(Get.WorkBook.1,1,FIND("]",Get.WorkBook.1),"")
3) The total number of pages (tabs) is now =COLUMNS(Get.Sheets)
4) The page number (order of tab, left to right) is now =MATCH(REPLACE(CELL("filename"),1,FIND("]",CELL("filename")),""),Get.Sheets,0)

Step (2) removed the [sheet-name] from the list returned by Get.WorkBook.1 in the same fashion as (4) does for the incident tab.

Caveats: CELL("filename") won't work on an unsaved workbook and, distressingly, you can't copy the formula about cell wise (you'll have to copy the formula from the formula bar). Sheet replication is OK though.
codger is offline   Reply With Quote
Old Apr 4th, 2002, 10:46 AM   #5
Ian Mac
MrExcel MVP
 
Join Date: Feb 2002
Location: Newcastle, UK
Posts: 1,174
Default

[quote]
On 2002-04-04 04:40, codger wrote:
OK, undeterred, I'm going to have a go at a formula based solution. I hope that,
The last bit should be 'H Mon' - the order the tabs are in the workbook.
the Actual sheets are Persons Name_Day, so are in no order in terms of numerical or alpabetical.

1) Create a name, say, Get.WorkBooks.1 that refers to =GET.WORKBOOK(1)

Not sure how to achieve this, to test I placed =GET.WORKBOOK(1) in a cell and get an Invalid Function message. Is it an add-in function?

2) Create another name, say, Get.Sheets that refers to =REPLACE(Get.WorkBook.1,1,FIND("]",Get.WorkBook.1),"")

This will return the same as 1)

3) The total number of pages (tabs) is now =COLUMNS(Get.Sheets)

4) The page number (order of tab, left to right) is now =MATCH(REPLACE(CELL("filename"),1,FIND("]",CELL("filename")),""),Get.Sheets,0)

Step (2) removed the [sheet-name] from the list returned by Get.WorkBook.1 in the same fashion as (4) does for the incident tab.

Caveats: CELL("filename") won't work on an unsaved workbook and, distressingly, you can't copy the formula about cell wise (you'll have to copy the formula from the formula bar). Sheet replication is OK though.

Unsure of what you mean by this?? By cellwise do you mean on different sheets, if yes you could put the option 2nd arguement in as a reference e.g. =CELL("filename",A1) to anchor it to that sheet.

I already use such a formula in the workbook:

=(VLOOKUP($B$5,StaffRota,VLOOKUP(RIGHT(CELL("filename",G3),3),{"Mon",2;"Tue",4;"Wed",6;"Thu",8;"Fri",10;"Sat",12;"Sun",14},2,0),0))

to direct the VLOOKUP to a particular Column on a schedule, determined by the day of the week in the sheet name.


I'm not sure a formula will cut the mustard, but I have been wrong many times before.
__________________
"Have a good time......all the time"
Ian Mac
Ian Mac is offline   Reply With Quote
Old Apr 4th, 2002, 11:12 AM   #6
codger
 
Join Date: Apr 2002
Posts: 23
Default

To create a name, use ctrl+F3 (define name) or select Insert from the menu, then name, then define.

In the dialog text entry enter your name 'Get.WorkBook.1', in the 'refers to:' entry at the bottom, enter (copy/paste) the formula I gave including the '=' char. It should be a formula; if it gets put in quotes, it's gone wrong.

You won't be able to dry run these 'name-formulas' in a worksheet. They belong to a hinterland of XL4 formulas that are information (as opposed to command or action based) and are OK in names but not in cells. It's this that stops you copying the cell contents.

As you didn't qualify my first remark, I presume that you aren't trying to sort these. The described solution will exhibit the 'page n of m' where m is the total and n is the tab number, left to right. If you need to select n with a criteria then you just (!) need to amend the formula to select n.
codger is offline   Reply With Quote
Old Apr 4th, 2002, 12:41 PM   #7
Ian Mac
MrExcel MVP
 
Join Date: Feb 2002
Location: Newcastle, UK
Posts: 1,174
Default

Quote:
On 2002-04-04 06:12, codger wrote:
To create a name, use ctrl+F3 (define name) or select Insert from the menu, then name, then define.

In the dialog text entry enter your name 'Get.WorkBook.1', in the 'refers to:' entry at the bottom, enter (copy/paste) the formula I gave including the '=' char. It should be a formula; if it gets put in quotes, it's gone wrong.

You won't be able to dry run these 'name-formulas' in a worksheet. They belong to a hinterland of XL4 formulas that are information (as opposed to command or action based) and are OK in names but not in cells. It's this that stops you copying the cell contents.

As you didn't qualify my first remark, I presume that you aren't trying to sort these. The described solution will exhibit the 'page n of m' where m is the total and n is the tab number, left to right. If you need to select n with a criteria then you just (!) need to amend the formula to select n.
Now I see, OK I understand the GET.WORKBOOKS(1) thingy.

I don't see how:

4) The page number (order of tab, left to right) is now =MATCH(REPLACE(CELL("filename"),1,FIND("]",CELL("filename")),""),Get.Sheets,0)

Would work on each sheet, the page number would be the same for each sheet (i.e. the last sheet that the formula is in)

changing to:

=MATCH(REPLACE(CELL("filename",A1),1,FIND("]",CELL("filename",A1)),""),Get.Sheets,0)

would stop this happening.

BUT! I will get there,

I'll explain:
My actual book currently has 61 pages in:

5 sheets of feeding data
7 sets of 8 sheets Monday-Sunday (currently).
Each of the Monday-Sunday has a summary sheet title TeamTotals&DayOfWeek.

Using your workings:

On 1 of the data sheets put:

=COLUMNS(Get.Sheets) in one of the cells, the result being 61

then put:

=(B4-(MATCH(REPLACE(CELL("filename",TeamTotalsMon!A1),1,FIND("]",CELL("filename",TeamTotalsMon!A1)),""),Get.Sheets,0)-1))/7

which is:

(No. sheets - (Sheet No of first summary - 1))/7

I have used 'TeamTotalsMon!A1' as the second arg in the CELL() to anchor it to that sheet (explained earlier)

the result being 8, thus far I have solved the Of how many sheets part and use =OfPages in those cells.

What I'm now looking is a way of the Page# being returned for each sheet. I'm playing with VLOOKUP to determin what to +/- as to which sheet number it actually is in relation to the number returned/7, if you follow.

Anyway I'm having a play with it now and should b able to work it out (head's fryed today).

Thanks for the help you've given, it's been extreely enjoyable (and eductional) playing with this and will continue to be.
By the way where can I get more info on XL4 thingies.

Many thanks,
__________________
"Have a good time......all the time"
Ian Mac
Ian Mac is offline   Reply With Quote
Old Apr 5th, 2002, 05:49 AM   #8
Ian Mac
MrExcel MVP
 
Join Date: Feb 2002
Location: Newcastle, UK
Posts: 1,174
Default

Quote:
On 2002-04-04 06:12, codger wrote:
To create a name, use ctrl+F3 (define name) or select Insert from the menu, then name, then define.

In the dialog text entry enter your name 'Get.WorkBook.1', in the 'refers to:' entry at the bottom, enter (copy/paste) the formula I gave including the '=' char. It should be a formula; if it gets put in quotes, it's gone wrong.

You won't be able to dry run these 'name-formulas' in a worksheet. They belong to a hinterland of XL4 formulas that are information (as opposed to command or action based) and are OK in names but not in cells. It's this that stops you copying the cell contents.

As you didn't qualify my first remark, I presume that you aren't trying to sort these. The described solution will exhibit the 'page n of m' where m is the total and n is the tab number, left to right. If you need to select n with a criteria then you just (!) need to amend the formula to select n.
I've cracked it!!!

I eventually worked out the Page# part. It turned out not to be difficult in the end. I simply set up a table of calculations for Mon, Tue etc. and minused the results from whichever sheet I was on via VLOOKUP().

I do have a couple of questions though:

If you need to select n with a criteria then you just (!) need to amend the formula to select n.

1) I don't understand this from your earlier post, It'll be me being slow but what is (!)?

2) The solution is top banana, however if I add sheets to the workbook, how do I get the =COLUMNS(Get.Sheets) formula to recalculate the number of sheets automatically. I've tried F9 (this isn't what I need anyway) and all the formula re-calc EXEPT that one.
At first I thought it was because it referenced the XL4 thingy BUT....

=(B4-(MATCH(REPLACE(CELL("filename",TeamTotalsMon!A1),1,FIND("]",CELL("filename",TeamTotalsMon!A1)),""),Get.Sheets,0)-1))/7

....this one works no probs???

The only way I managed to get it to re-calc was to enter then leave the cell.

Any reason for this??
__________________
"Have a good time......all the time"
Ian Mac
Ian Mac is offline   Reply With Quote
Old Apr 5th, 2002, 09:16 AM   #9
codger
 
Join Date: Apr 2002
Posts: 23
Default

Ian,

The re-calculation 'problem' is a feature of Excel. Unless functions are marked to recalculate without their arguments changing (so called 'volatile' functions) F9 and shift F9 perform re-calcs only on cells that can be traced to a changed cell (so called 'dirty' cells). What is happening in your sheet is that Excel can't trace any cell dependents for your formula and, after an initial calculation when the book is opened, won't perform a re-calculation.

Fortunately you can tell Excel to do a calculation of cells even if they are 'clean'; by ctrl+alt+F9. As I often work with custom functions, I've got into the habit of doing that.

One other calc thing; I noticed that on my trial sheet (could I post this to the board somehow?), using =CELL("filename") to get the tabs isn't suffcient. This returns the tab of the active cell and a recalc will cell all the formulas to this tab-name. What should be done is =CELL("filename",A1) where 'A1' is any relative reference and hence 'anchors' the cell to the tab name and so makes these all different.

I see by your latest post you've already done this - that was a good spot.

Thus, if your end goal was to be able to print the whole workbook, then after collating by hand, each recipient would have numbered copies. Was this what was wanted?

To do this last part, to get {"Ant Mon","Cat Mon","Ant Tue","Cat Tue"} to separate to Ant's 1 or 2, 2 of 2 etc. you need to stop retrieving '3' for the second Ant (Tue); it is the third sheet but only Ant's second. This is a bit messy. If you're not trying to do this I won't burden the post with the formula, but if you are just shout.

[ This Message was edited by: codger on 2002-04-05 04:18 ]
codger is offline   Reply With Quote
Old Apr 5th, 2002, 10:16 AM   #10
Ian Mac
MrExcel MVP
 
Join Date: Feb 2002
Location: Newcastle, UK
Posts: 1,174
Default

Quote:
On 2002-04-05 04:16, codger wrote:
Ian,

The re-calculation 'problem' is a feature of Excel. Unless functions are marked to recalculate without their arguments changing (so called 'volatile' functions) F9 and shift F9 perform re-calcs only on cells that can be traced to a changed cell (so called 'dirty' cells). What is happening in your sheet is that Excel can't trace any cell dependents for your formula and, after an initial calculation when the book is opened, won't perform a re-calculation.

Fortunately you can tell Excel to do a calculation of cells even if they are 'clean'; by ctrl+alt+F9. As I often work with custom functions, I've got into the habit of doing that.

One other calc thing; I noticed that on my trial sheet (could I post this to the board somehow?), using =CELL("filename") to get the tabs isn't suffcient. This returns the tab of the active cell and a recalc will cell all the formulas to this tab-name. What should be done is =CELL("filename",A1) where 'A1' is any relative reference and hence 'anchors' the cell to the tab name and so makes these all different.

I see by your latest post you've already done this - that was a good spot.

Thus, if your end goal was to be able to print the whole workbook, then after collating by hand, each recipient would have numbered copies. Was this what was wanted?

To do this last part, to get {"Ant Mon","Cat Mon","Ant Tue","Cat Tue"} to separate to Ant's 1 or 2, 2 of 2 etc. you need to stop retrieving '3' for the second Ant (Tue); it is the third sheet but only Ant's second. This is a bit messy. If you're not trying to do this I won't burden the post with the formula, but if you are just shout.

[ This Message was edited by: codger on 2002-04-05 04:18 ]
How then can I use Ctrl+Alt+F9 in VBA.

with the:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

End Sub

would suffice.

the e.g. {"Ant Mon","Cat Mon","Ant Tue","Cat Tue"} you gave.
I needed Ant to be page 1 on both occations

Re: that Page# part EUREKA! I did get it and as I've said, the solution was easier than first thought, simple maths one # minus another. (and they say we don't remember things from school )

Thanks again, hope you know the VBA bit, but not to worry if you don't you've saved a lot of future headaches.

__________________
"Have a good time......all the time"
Ian Mac
Ian Mac is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


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


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes