Is it possible to reference Cells via Cells in Microsoft Excel - 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))

Related

What function do I need for getting year-to-date % increase over prior year?

I have an excel workbook for multiple restaurants that has sheets for every year labeled with their sales per month. I am attaching an example of one row of the sheet for the year 2020. I would like to have a cell at the end of each row that shows the % increase or decrease over the prior year up to the last month entered. It would be pulling the information for the results from the prior sheet. I don't know which function to use or how to get the function to only add the corresponding months to date from last year. For example, on the sheet for 2020, sales are listed through July but the sheet for 2019 has all 12 months listed. I would like to include a cell that gives me the year-to-date % through whatever current month it is.
Sheet for Year 2020
If you want to use only the columns filled in the current year in the percentage calculation, you can use following formula:
=SUM(B3:M3)/SUMPRODUCT(B2:M2*(B3:M3>0))-1
First count how many cells are blank in your current year using the
=COUNTBLANK()
Then sum up the year you are comparing to starting at january then going 12 - result of blankcells formula to the right.
=SUM(OFFSET(JANUARY_CELL_REF, 0, 0, 1, 12-COUNTBLANK(this_year)))
Then you just divide it by the results this year so far:
=result_So_far_this_year / SUM(OFFSET(JANUARY_CELL_REF, 0, 0, 1, 12-COUNTBLANK(this_year)))
Finally format is as a percent.

excel vba shifting formulas based on sales lead time

I trying to find the correct code to move my formulas over x number of cells. The x would represent sales lead time. Lets say I make a January sale, but that revenue wont actually be received until 7 months later. So for Jan I wont receive until July, for Feb I wont receive until August, for March I wont receive until September and so on.
I'm looking for something to automate or shift my formulas that total my sales over based on a lead time cell. So lets say I change my lead time to 5 months everything shifts over to reflect 5 months instead of 7.
Any help would be greatly appreciated.
Hope thats not too confusing.
Thanks for any help!
You seem to be looking at the problem from the wrong end: Instead of asking when your January sales proceeds will be received, try asking which proceeds you will receive in July. Then you arrive at a structure like this:-
Column A = Date of sale
Column B = Description
Column C = Sales amount
Column D = Expected delay in months
Column E and up = Jan, Feb, etc. one column for each month
Write the starting date in cell E1, say 1/1/2017.
In F1 paste this formula: =DATE(YEAR(E1),MONTH(E1)+1,1)
Format the range E1:F1 as 'Custom' using the string MMM yy
Copy F1 to the right as far into the future as you require
Now you have a column for each month. If you change the value in E1 all captions will change accordingly. That's good when you need a new sheet for next year.
Write this formula in E2: =IF(MONTH($A2) + $D2 = MONTH(E$1), $C2,0)
Copy right and down as far as you require
Now, make an entry. Say on Jan 17 you had a sale of $1200 and you expect to receive the money 6 months later.
Enter the date in column A = 17/1/2017
Enter the amount in column C = 1200
Enter the expected delay in column D = 6
The amount appears in the July column. Change the value in column D to 3 and the amount moves to April.
All the other columns show a zero. If you don't like that, go to File ->Options -> Advanced >>Display options for this worksheet = uncheck the checkbox for "Show a zero in cells that have zero value".

Excel Pivot table count between

I have a problem creating a pivot table/chart with between date function.
I would like to know the total count of projects that are active between two dates. A Chart with on the x-axis week 1 - week 52 is what i'm trying to create.
Example Chart
20
10
5
0
week 1 week 2 week 3 .....
My columns:
Project ID | START WEEK NUMBER| END WEEK NUMBER
What have I already done?
Adding helper columns 1 till 52 with the following function:
=IF(AH$1=MEDIAN($AB10;$AD10);1;IF(AH$1=$AB10;1;IF(AH$1=$AD10;1;"")))
This will show a 1 when the column week header is equal or between date start week and end week. But with this I am still not able to create a chart with the weeks on the x-axis and the total count of that week.
Make a new sheet and in Column A put your weeks 1-52 down. In column B use this formula:
=COUNTIFS(Sheet6!$B$2:$B$18,"<="&A2,Sheet6!$C$2:$C$18,">="&A2)
Sheet6! Needs to be replaced with the name of your Sheet, e.g. Projects!
Column B range needs to be the entire range of your start week
Column C range needs to be the entire range of your end week
B and C dimensions need to match.
If you need to use a pivot table, try rearranging your source data as shown:

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

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.

Excel | Formula to find total amount in this situation

Assume that we are currently in the month March. I have a table with all the months and a list of products. Inside each column i have the number sales a product has made on that month, like so:
Notice i have a cell containing "Total until current month". I would require a formula to find out the total amount of sales of a specific product (product A for example) up until March (current month) as you can see with the manually typed 6, 1 in Jan and 5 in Feb.
I would usually do this by finding the sum of cell C4 and D5. But this should be 1 dynamic formula that is updating as we progress onto next month. So as an exammple, in April, it will find the sum of cell C4 - E5 (Jan - March) and update the value.
Is this possible?
Regards
Put a helper row above the month names that has the month numbers 1-12.
Then use SUMIFS():
=SUMIF($C$2:$N$2,"<=" &MONTH(TODAY()),C4:N4)
You could hide that row so it is not visible and not readily accessible.
In row 3 put month numbers. Now if in cell Q4 you have a month number that you want to relate to use:
=SUMIF($C$3:$N$3,"<"&$Q$4,C5:N5)
for sum of A and drag down for other products.
If you want to pick the product you want sum for and have it all in one cell, then assuming that in cell R4 you have your product name (e.g. "B") write
=SUM((C3:N3<Q4)*C5:N6*(B5:B6=R4))
and press ctrl+shift+enter.
The simplest solution is to leave E4 through N4 empty. Only put a value in E4 once March is complete and you have a value for March. This will allow a formula like:
=SUM(C4:N4)
for Product A

Resources