Solved

Add rows dynamically

Posted on 2011-09-15
5
176 Views
Last Modified: 2012-05-12
I have a spreadsheet I am making up for holidays (attached) and I want to produce a list as part of the sheet that dynamically shows the days being taken off.

In the example there was a full day taken (8 hours) on 1,3,6 and 8 October and a half day taken on 2 and 15 October.
What I want to do is to add a new row in before the totals row (row 13) each time holidays are taken so that you can see the date easily and the total days taken.

So for example, if a half day off (4 hours) was taken on 20 October, A13 would change to “20-Oct-11”, B13 would change to “0.5”, A14 would change to “Total” and B14 would change to “5.5”

I don’t want to use VBA for this if it can be done in another way.

Thanks

Holiday.xlsx
0
Comment
Question by:GordonMasson
  • 3
  • 2
5 Comments
 
LVL 2

Expert Comment

by:Hernan_Cano
ID: 36544939
You can use pivot tables.

I have attached an example of a possible solution.

Holiday-PivotTable.xlsx
0
 
LVL 2

Expert Comment

by:Hernan_Cano
ID: 36544955
Some notes:

- For setting the daily titles, change only the value in C1.
- You can change the day-hours equivalency.
- After any change, you have to right click in the pivot table and select "refresh" to update it.

The pivot table uses the same information in a different format (set in Sheet2) for easier and more flexible formatting.
0
 

Author Comment

by:GordonMasson
ID: 36547979
Hi Herman

Looks great.
I have a question though. I am going to run this for a calander year so i need the dates in sheet 2, column B to look like you have set up.......
=Sheet1!C2
=Sheet1!D2
=Sheet1!E2

If i set B2 and then drag it down the row number changes rather than the column number.
How do i change it to mak it the column number that changes?

Thanks
0
 
LVL 2

Accepted Solution

by:
Hernan_Cano earned 500 total points
ID: 36551952
For this particular example you can use in column B:

 
=IFERROR(INDIRECT("Sheet1!" & SUBSTITUTE(ADDRESS(1,ROW()+1,4),"1","") & "$2"), "0")

Open in new window


This gets the column dinamically according to the row number where it's used with ADDRESS.
Then it strips the number from the address with SUBSTITUTE.
Next we get the required value from the Sheet1 with INDIRECT using the calculated letter and fixed number.
Finally I added zero as the default value in case anything goes wrong in the formula.
0
 

Author Closing Comment

by:GordonMasson
ID: 36572518
Thanks for your help
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question