Computing.Net > Forums > Office Software > Excel Tabs

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Excel Tabs

Reply to Message Icon

Name: Bud Parker
Date: February 24, 2008 at 15:35:48 Pacific
OS: XP Pro
CPU/Ram: x86 Family 6 Model 13 Ste
Product: Dell/Latitude D610
Comment:

Excel 2003: I'm building a "Cost Sheet" that will use a different tab for each day of the month. Each Daily Tab will import total from the preceeding days tab.

Any easy way to create this?

Thanks in advance...



Sponsored Link
Ads by Google

Response Number 1
Name: DerbyDad03
Date: February 24, 2008 at 19:40:56 Pacific
Reply:

re: Any easy way to create this?

Create what? A workbook with 31 tabs? Or the functions required to import totals from previous day's tab?

The following code will create a workbook with 31 tabs, named Day 1 - Day 31. As far as the other question, you'll need to be a lot more specific.

Note: This code will rename the existing sheets in a workbook (new or old) to Day 1, Day 2, etc. and then add enough sheets to get you to Day 31, all named appropriately.

Sub DailyTabs()
'Rename Existing Sheets
For Shts = 1 To ActiveWorkbook.Sheets.Count
ActiveWorkbook.Sheets(Shts).Name = "Day " & Shts
Next
'Add more sheets and rename them
For NewSht = ActiveWorkbook.Sheets.Count + 1 To 31
ActiveWorkbook.Sheets.Add After:=Worksheets(Worksheets.Count)
ActiveWorkbook.Sheets(NewSht).Name = "Day " & NewSht
Next
End Sub



0

Response Number 2
Name: Bud Parker
Date: February 25, 2008 at 09:34:35 Pacific
Reply:

Thanks! I can see that you are far advanced in Excel.

The code you kindly provided... Where do I apply this data to create these tabs?

Lastly, the tabed worksheets will import the previous day's "Total Costs" column into the next day's "Previous Costs" column.

Thanks again for helping this poor old rookie out! I work offshore in the Gulf of Mexico and I'm sort of stuck for finding a good Excel source of education.

1sgparker@gmail.com


0

Response Number 3
Name: DerbyDad03
Date: February 25, 2008 at 10:53:02 Pacific
Reply:

Part 1 of 2: Creating the Tabs in a workbook -

To use the code to create a workbook with 31 tabs, do the following:

Select all the code above, including everything from Sub DailyTabs() to End Sub

Open a new workbook. Click on Tools...Macro...Visual Basic Editor.

This should open a window where you can paste the code into. If it doesn't, Click on Insert...Module.

Paste the code in the window and either click Run...Run Sub/UserForm, or click the little green arrow in the toolbar or hit F5.

Note: if you run this in a existing book that has data in it, I suggest you create a backup copy first in case something goes terribly wrong.

Your workbook with 31 tabs should be created.


0

Response Number 4
Name: DerbyDad03
Date: February 25, 2008 at 11:32:33 Pacific
Reply:

Part 2 of 2 - Creating the formula to pick up the previous day's totals.

(This took a bit of research and trial and error, but I think it does what you want.)

1 - In your 31 tab workbook, click on Insert...Name...Define

2 - In the Names In Workbook field enter something like PrevDayTotal or anything other name that you will remember.

3 - In the Refers to field, paste this formula:
=INDIRECT(INDEX(GET.WORKBOOK(1),GET.DOCUMENT(87)-1)&"!"&ADDRESS(ROW(),3))

Note: the 3 near the end represents the column number that holds the Total Costs in each sheet (I assume it's the same for each day) In this case I choose Column C (3). You should change that value to match your column.

4 - Select the tab for Day 2, hold down the shift key and select the tab for Day 31. This should highlight all the tabs, which means that whatever you do in one sheet, you will do to every selected sheet.

5 - In the first cell where you want the previous day's value, enter =PrevDayTotal or whatever name you chose for this function.

6 - Drag the "formula" down as many rows as required to pick up all the values from the previous sheet.

What should happen is that the PrevDayTotal function will look back 1 sheet and return the value in the same row and whatever column you used in the "Refers to" field.

Let me know if this works for you.



0

Response Number 5
Name: DerbyDad03
Date: February 25, 2008 at 19:34:23 Pacific
Reply:

Hold on, we have an issue!

This portion of the formula I offered has a problem: GET.DOCUMENT(87)-1

It returns a #REF error if the sheet names have a space in them. It also fails when there is a -, and a few other characters. I don't quite know why.

Anyway, the solution is to name your sheets Day1 or Day_1 or something like that. If you get the #REF error, it's mostly because you used a character in the sheet name that the formula doesn't like.

If you change the orginal code to read as follows, it will create tabs that like Day_1 and everything should be fine.

Sub DailyTabs()
'Rename Existing Sheets
For Shts = 1 To ActiveWorkbook.Sheets.Count
ActiveWorkbook.Sheets(Shts).Name = "Day_" & Shts
Next
'Add more sheets and rename them
For NewSht = ActiveWorkbook.Sheets.Count + 1 To 31
ActiveWorkbook.Sheets.Add After:=Worksheets(Worksheets.Count)
ActiveWorkbook.Sheets(NewSht).Name = "Day_" & NewSht
Next
End Sub

Sorry about that, I didn't test both parts of my suggestions as a "complete package". Now I need to go off and find out why you can't have a space or - in the sheet name.


0

Related Posts

See More



Response Number 6
Name: Bud Parker
Date: February 26, 2008 at 05:59:54 Pacific
Reply:

Part 1 - Success! I can figure out how to modify the VBE code if necessary. I'll likely just call each day 1, 2, 3, etc.

The cell addresses I am trying to import from the "Previous Day" is H13:H105. I bet that makes this easier.


0

Response Number 7
Name: DerbyDad03
Date: February 26, 2008 at 10:25:56 Pacific
Reply:

Not sure how H13 - H105 makes anything "easier".

If the goal of this exercise was to find an easy way populate all 31 sheets with the formulae, then my suggestion of using a Defined Name still fits the bill. Simply change the 3 to an 8, and it will pull values from column H instead of C.

Meanwhile, I'm working on a solution that will allow you to use any sheet name.


0

Response Number 8
Name: DerbyDad03
Date: February 26, 2008 at 18:03:20 Pacific
Reply:

OK, I needed some help from an expert on this one. We don't know exactly why my original suggestion fails with certain sheet names (such as sheet names with spaces) but we're pretty sure this one will work for any valid sheet name.

Follow the same procedure to create a named range:

1 - Insert...Name...Define
2 - Enter some text in the Names box
3 - Paste this into the Refers to: box
4 - Click OK

=INDIRECT("'"&MID(INDEX(GET.WORKBOOK(1),GET.DOCUMENT(87)-1),FIND("]",INDEX(GET.WORKBOOK(1),GET.DOCUMENT(87)-1))+1,255)&"'!"&ADDRESS(ROW(),3))

Enjoy!


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Excel Tabs

excel - tab or arrow key don't work www.computing.net/answers/office/excel-tab-or-arrow-key-dont-work/2932.html

excel tabs have disappeared www.computing.net/answers/office/excel-tabs-have-disappeared/7947.html

MS Excel tab key www.computing.net/answers/office/ms-excel-tab-key/4271.html