Solved

Add rows dynamically

Posted on 2011-09-15
5
174 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for your help
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now