i want to have a single column containing different values for each month - excel

I have created a table in excel for keeping the leave records of staff. I created a scroll bar to scroll to a different month. I have added an extra column named "leave this month" which shows how many days a person has taken leave. but when I scroll to a different month (for example from January to February) the column's data stays the same. I want it to have different data for different months. for example for January it is 3 days, for February it is 4 days and... I want different values in the same cell for different months.(when I scroll to a different month the value should change) do you guys know how to do that?
screenshot
Sub showcalendar()
LeaveTracker.Columns("C:NJ").Hidden = True
LeaveTracker.Range(Columns(Range("B3").Value * 31 - 28),Columns(Range("B3").Value * 31 + 2)).Hidden = False
End Sub

Here is the approach I would use:
Define a spreadsheet with 31 X 12 columns (each group of 31 columns would represent a month, even for those cases when the month has 28/29/30 days); this spreadsheet will be use as the storage of the raw data (i.e. presence/absence of a person each day of the year),
A second spreadsheet to be use for display will have the cells linked to the first one with an horizontal offset (to the right) to be calculated as 31 * (month_number - 1); as such, when looking at the information of March, the offset would be 62 columns to the right.
Your scrollbar would run from 1 to 12 and set the value of the month (which would then be used to calculate the offset.
In this way, you don't need to copy-paste anything and, instead, you have a sliding "window" that runs right and left over your raw data sheet.
Hoe this description is clear.

So you basically have 365 columns for each day of the year. On row 4(or wherever suitable) add the month number i.e. for the first 31 columns, cells will have 01 in row4. For the next 28 columns cells in row 4 will have 02 and so on.
then in NK8, the formula to be entered should be
SUMIF($C$4:$NJ$4,$B$3,C8:NJ8)
which you can drag down for each person. B3 ahs the current month number you are viewing. The formula basically sums only those cells whose corresponding cell in row4 matches the month number in B3.
Here is a Google Sheet example.

Related

Need to revise this formula that displays data based on another cell's contents

I can't get this formula working properly. Here is what I need to do (see included image below):
I need the data in rows 9-10 (sales) to be displayed/copied in rows 28-29 (collections) based on the number in cells C9 and C10 (payment terms). For example, if there are $1,900 in GM sales on Tuesday, Jan 5 (cell F9) and payment terms are 10 days (cell C9), then I need $1,900 displayed on Tuesday, Jan 19 (cell P28), in the collections section (rows 28-29), 10 business days from when the sales were made. Does this make sense? Here is the formula I am using now (starting in cell E28 and being dragged to the right):
=IF(COLUMN() - E9 < 1, 0, INDIRECT(ADDRESS(9, COLUMN() - $C$9)))
However, it is not working completely. It is moving the data labels to the left of the data table that are not supposed to be included in the data table. Only sales data starting in cell E9 are supposed to be moved. You can see this issue in row 28 (columns J-N) in the image below.
This formula also has to work with payment terms from 1 day - 10 days. So, the $5,000 in Ford sales on Monday, Jan 4 (cell F10), with payment terms of 3 days (cell C10), needs to be displayed on Friday, Jan 8 (cell I29).
Let me know if you need any additional details to solve this issue. Thanks!
Is this what you're looking for?
=IFERROR(INDEX($E$9:$X$13,MATCH($B28,$B$9:$B$13,0),MATCH(WORKDAY(E$5,-INDEX($C$9:$C$13,MATCH($B28,$B$9:$B$13,0))),$E$5:$X$5,0)),0)
The formula indexes the sales amounts and shows the amount in the row where the customer name mentioned at sales equals the customer at the result section with the column where the result date equals the date mentioned at sales minus the number of workdays mentioned behind the customer name at the sales section.

Sum current and prior year month-to-date to corresponding day of month

In the picture, I have a running monthly total at the bottom for THIS YEAR. I have Last Year already populated. How can I have LY monthly total only populate to where I am currently today?
Generalising (for lack of a clear requirements statement - but conveniently then possibly of wider relevance) if you have two columns of numeric values with one (say A) of 31 entries and a column label (in Row1) and the other (say B) of 15 entries and column label and you want to add both down only as far as the shorter column is populated then you might:
In B32 enter =SUM(B2:B31) - to derive the "current month to date" total.
In A32 enter =SUM(INDIRECT("A1:A"&MATCH(1E+100,B1:B31,1))) - to derive the sum of the same rows (but different column) as above.

Transfer data from one worksheet to the next based on cell values

I had trouble titling this, and I think it is better explained with examples. I am not an extremely experienced excel user, but was asked to figure this out.
Worksheet 1 (delivered by software) is formatted like this:
12/17/2013
Hour Delivered
00.00-00.59
Employee 1 18
Employee 2 17
Total For Hour 35
01.00-01.59
Employee 1 18
Employee 2 17
Employee 3 12
Total For Hour 47
... etc until hours 24.00-24.59
The number of employees in the group per hour is different each day, so i don't think that I can just simply reference the cells.
The worksheets that I want to transfer the data from worksheet 1 to are based on date, so there is one for each day. (12/17 worksheet, 12/18 worksheet, etc...)
And this is the format of the date worksheets:
Employee 00.00-00.59 | 01.00-01.59 | etc. until hours 24.00-24.59
Employee 1 18 18
Employee 2 17 17
Employee 3 12
Employee 4
Employee 5
So basically I need the data from worksheet 1 transferred over to the individual date worksheets. I believe, the amount of employees being different for each hour/day makes this difficult. Does anyone here have any ideas of how this can be accomplished?
Also, if there are any questions, please let me know.
This should be possible without any VB in two steps. First step is to add further columns to Worksheet 1 that normalise the data. Second step is to create a pivot table using that normalised data.
By "normalise" I mean add columns in Worksheet 1 for Date, Hour, Employee and Delivered using formulae that copy values from your existing columns A and B. Let me know if you need more help with that.
Edit: adding details ...
Suppose Worksheet 1 has the values you indicated in column A and B, and that you want Hour in column D. Suppose row 1 just contains column headings. Leave row 2 totally empty. The formula in col D needs to say "If the value in col A looks like an hour, then copy it, otherwise repeat the hour from the line above." A simple way to determine if a row in Worksheet 1 is an Hour is to look for a decimal point in position 3. So put =IF(MID(A3,3,1)=".",A3,D2) in cell D3 and copy that formula down.
I'm sure you can construct a similar formula for the Date, Employee and Delivered columns.
Maybe add a condition to the formulae to say "If the value in col A starts with 'Total' then leave the cell empty".
If there aren't a lot of data and the setup is exactly how you've displayed them above, a simple formula can solve this.
Assuming that my raw export is in sheet Base, cell A1 and my intended output starts in sheet Output, cell A1, you can use this formula on cell B2:
=IF(INDEX(Base!$A:$A,MATCH(B$1,Base!$A:$A,0)+ROW(1:1),0)=$A2,OFFSET(INDEX(Base!$A:$A,MATCH(B$1,Base!$A:$A,0)+ROW(1:1),0),0,1),0)
The premise is simple. It locates the correct hour using INDEX + MATCH, then OFFSETs it by the correct number of ROWs. This is assuming, of course, that your employees are in the same location under every hour (ie Employee 1 is always one (1) row below the hour, Employee 2 is always two (2) rows below, etc). We also add a check if the employee name matches so that it will return 0 if the employee is not there.
Here are some screencaps:
Sample data:
Output:
Of course, this is just the basic premise. If you have multiple dates in a sheet, it's just a matter of manipulating this formula further. Off the top of my head, locating the correct date and adding the correct offset can also work.
Let us know if this helps or if a VBA or the Pivot option seems best.

Is it possible to reference Cells via Cells in Microsoft Excel

In a spreadsheet i'm trying to fix up, on the final page i want it to gather totals, so far this is the structure
Month | Year | Month Start | Month End | Month Total
how this supposed to work is that the user enters the month and year then inputs the start and end rows (Month Start and End) of another page, this other page will contain records of transactions made with each transaction being a separate row, this can mean one month can have 5 transaction while another may have 50
i'm making the assumption that the user doesn't now how to reference data from another sheet so how i want to try and implement it so that they add the row numbers to Month Start and End and Month Total will generate the formula
eg.
Month Start = 4
Month End = 6
Formula Generated in Month Total = "=SUM(Transactions!E4:E6)"
if the user changes Month End to 9, the formula generated above will change the E6 part to E9, like i said above, each row in the Transactions sheet is a transaction and there can be variable number of transactions a month
what i am asking is if it is possible to references cells like this
Take a look at the INDIRECT function
You can use the OFFSET function to generate offsets from a starting point.
Assuming your layout is like this:
A B C D E
1 Year Month Start End Total
2 2012 Jan 4 9 =sum(...)
The total column (cell E2) could have the formula:
=SUM(OFFSET(Transactions!E1,C2-1,0,(D2-C2)+1))

Excel: Trailing 3 month decline using data from a pivot table

(http://stackoverflow.com/questions/5283466/calculate-moving-average-in-excel seems to be somewhat related. I'm curious to know the non-vba way to do this.)
My my pivot table has source data that creates a count of how many sales a person had in the past 36 days. Each day os 1 column in the pivot table, and the persons name is on the row.
Some of these people did not have sales on day1, day2, etc, and may only have 3 days where they sold something on days 14,15 and 16. No matter what their sequence, I want to to find the most recent sale data (closest to the right edge of pivot table) and calculate three sales increases e.g. C20/C19 will be >1 if they had more sales on the whatever day C20 is. The increase ca nbe fond by subtracting 1 and changing to percent. The problem is, if a person only had sales on d10, d11, d12 then how can I put a general formula in Excel to say "look for the most recent consecutive sales, then calculate this ratio"? For a person who had sales in the past three days, that's easy. It will be chaotic to hardcode where to look for each sales value.
d1 d2 d3 d4...d7 d8 d9...d34 d35 d36 mostrecentincrease nextrecent
ant 1 5 7 7/5=1.4 5/1=5
bat ...10 11 12... 12/11=1.blah 11/10=1.1
cat 2 6 9 13
dog 19 20 20/19=1.blah 19/blank=0
elf 4 4/dnexist=0
i don't have excel here, but i hope this will guide you to the correct result (use , instead of ; if that is your list separator):
define sales as a range of values from d1 to d36 for a given row (or use actual ranges)
compute positions of the last values for each row using these array formulas (use ctrl+shift+enter instead of just enter after you write these formulas):
position_1 =max(if(sales<>0;column(sales)))
position_2 =max(if((sales<>0)*(column(sales)<>position_1);column(sales)))
position_3 =max(if((sales<>0)*(column(sales)<>position_1)*(column(sales)<>position_2);column(sales)))
retrieve the values:
value_1 =index(sales;position_1)
do some error handling (=iferror(...;0)) and the like...

Resources