EXCEL - retrieve value of specific cell in column based off of date - vba

My question is as follows:
I have an excel workbook with two worksheets. The first worksheet has my bills listed in rows, and paydates in columns. The second worksheet has a weekly cashflow plan with spots corresponding to various bills in the first.
I would like the cash flow worksheet to update the cell to the dollar value of the bill if its due. I have attached a link to my box with the excel file. Screen shots are below as well. In the screenshot examples, for instance, i would like the Electricity Cell in Cash flow sheet to Show $238 since the Electricity in the Bills sheet for the current week has an X in that location.
Excel Workbook
Any help that can be provided would be greatly appreciated.

If I understand what you want to accomplish correctly, your dates on the first worksheet (E3, F3, etc) need to be changed to Thursday dates - they are Wed dates right now.Also, you need the descriptions in column B of the first sheet to exactly match the descriptions in column A of the second sheet. This is why accountants like to use account numbers instead of account descriptions when possible.
If you change those here are your formulas:
Second sheet cell A2 - =IF(WEEKDAY(A3)<=5,A3+5-WEEKDAY(A3),A3-WEEKDAY(A3)+7+5). This checks the day of week of the current date then adds days as needed. It seems like there might be an easier way to get this.
Second sheet cells B6, B7, B8, B10 ,etc = =IF(HLOOKUP(A10,$F$4:$J$8,MATCH(A12,$D$5:$D$8,0)+1,FALSE)="x",VLOOKUP(A12,$D$5:$E$8,2,FALSE),""), The hlookup determines if there is an "x" in the current week and the vlookup pulls the amount from the correct line.

Related

MAX function : Display name of sheet where the answer is

I have several sheets in my Excel file, all named according to a day of the month (So from 1 to 31). I also have another sheet named "totals". In this sheet I have a MAX function that returns the highest number in cell Q31 from ALL sheets. In short, I ask to Excel: What is the highest number among the 31 "Q31" cells. Excel gives me the answer, for example, 54.
I would rather have Excel give me the name of the sheet where it finds the answer.
Is it possible?
Thanks!
In A1 through A31 enter:
=INDIRECT(ROW() & "!Q31")
then in B1 enter:
=MATCH(MAX(A:A),A:A,0)
(assumes the sheets are "named" 1,2,3,... and the worksheet name corresponds to the row number in column A)

Highlight X number of cells based on numeric value

I'm creating a vacation tracker in excel. The first sheet pulls the data from SharePoint which has Start Date, End Date and a Date Difference calculation.
Sheet1
A2=12/16/2015
B2=12/20/2015
C2=5
The second sheet is the visualization of the data. It starts with cell B1 and goes out for 90 days. It is a word representation of the date. Here is the formula I'm using =UPPER(TEXT(B2,"DDD"))
Sheet2
B1=WED
C1=THU
D1=FRI
E1=SAT
F1=SUN
The next row always B2 has a formula which is always today's date. From there I add one date to increment the dates out to 90 days. B2=Today() and the other cells =B2+1 and so forth
B2=16
C2=17
D2=18
E2=19
F2=20
What I'm trying to do is have the start date and end date highlighted on Sheet2. For example the boss is out on vacation from 12/16/2015 until 12/20/2015. I need the cells B3-F3 on Sheet2 highlighted in Red. The secretary who is on leave from 12/17/2015 to 12/19/2015 have her cells highlighted in another color from cells C4-E4.
This will probably take some VBA I just need a starting point. I tried using a VLOOKUP to pull the data, however the using a range from another sheet is not working. And to be honest I do not know if this is the correct approach.
Conditional formatting for B2:ZZ2 at Sheet2
=AND(B2>=Sheet1!$A$2,B2<=Sheet1!$B$2)
And select the color you like

Index and Match Excel

I'm creating a vacation tracker in Excel. The first sheet pulls the data from SharePoint which has Start Date, End Date and a Date Difference calculation.
Sheet1
A2=12/16/2015
B2=12/20/2015
C2=5
The second sheet is the visualization of the data. It starts with cell B1 and goes out for 90 days. Is is a word representation of the date. Here is the formula I'm using =UPPER(TEXT(B2,"DDD"))
Sheet2
B1=WED
C1=THU
D1=FRI
E1=SAT
F1=SUN
The next row always B2 has a formula which is always today's date. From there I add one date to increment the dates out to 90 days. B2=Today() and the other cells =B2+1 and so forth
B2=16
C2=17
D2=18
E2=19
F2=20
The problem I'm running to is that our boss can have 3 calendar entries consisting of different dates. So when I perform a SharePoint pull I have 3 different rows of vacation dates. I'm experimenting with an Index and Match example, however the data match it is placed in a new row. How do I place the data on the same row?
I'm not convinced this has much to do with VBA. Seems enough detail of final design but rather light on the data gathering process. However when I perform a SharePoint pull I have 3 different rows of vacation dates hints at a use for Subtotal. Three rows may be 'converted' into one:
where the unshaded part (some cells with Xs) is assumed to be a representation of the current SharePoint data extract. Subtotal is able to add the rows shown lightly filled, which might then be used to =VLOOKUP("Boss"&" Count",A:F,n,0) where n represent the choice of column label.

VBA - Sum multiple rows where adjacent column value matches another cell

Basically, I have two worksheets - one lists all jobs completed in a day and in the 'Sales' column I have:
{=SUM(INDEX(equip!K:K,MATCH('Page 1'!F2,equip!A:A,0)))}
in each cell. The other sheet (equip) has a list of all the equipment used at each job. I'm trying to SUM the rows where the customer name is found on both sheets. Customer names are in column A of the equip sheet.
Any help would be awesome! I'm stumped.. It's probably a small error somewhere I hope.
A standard (non-array) native worksheet formula based upon the SUMIF function should do well here.
=SUMIF(equip!A:A, 'Page 1'!F2, equip!K:K)
If you actually need that in VBA then the code line would be something like,
With ActiveSheet
.Range("A1").Formula = "=SUMIF(equip!A:A, 'Page 1'!F2, equip!K:K)"
End With

Excel Formula to calculate number of user hits in a system everyday

This is the continuation of my previous questions and I have included my global aim with project.
Excel Link:
https://drive.google.com/file/d/0B5W4CgZKsARFSmhqV0ZSM1lBSkE/view?usp=sharing
Task:
The task is to collect the "number hits" of a user in an application "on each day". I can collect a log from the system which will give me the name of the users and their last hit date and total number of hits.(This total number of hits in not on daily basis, but sum of all days). and I need to make a formula to segregate these on daily basis
Screenshot:
To understand in better way I have created few screenshot, which I am looking to implement.
The excel has two tabs raw_data and value_capture. I will use raw_data to paste my raw data collecting from system log and value_capture to generate day by day hit statistics
Raw_data tab:
It has three details, 1. date. 2. name and 3 totals hits(This total hits are overall hits of that user on all days)
value_capture:
This has all user names and all dates to mark each day and a column to display all hits.
Now, considering an example of date 20141120, all users hits are 0.
raw_data shows 0 against all users
so value_capture are has to be updated with same
Now on next day 20141121, there is some hits against some users. (Note : if there is no hit against a user, it will only the previous date ie,date will update only if there is a hit on that day)
value_capture updated with that details
On 20141122, there are some more hits against the users
value_capture updated with the details. since the raw_data will show total number of hits against a user, the way of calculating on a particular will be total hits- previous date hit
I am stuck at a way to develop the excel formula here.Looking for an idea to implement this.
Note :
Users name will be fixed on both tabs, but that may come in different order in raw_data tab.
UPDATE
My raw_data sheet will be updated everyday and I want my formula results be fixed in the value_capture sheet after the values are updated (removed) from sheet raw_data
So as i mentioned in my answer to your previous question, the only way to save the results of a formula after deleting/removing its reference cells, is to use a macro.
First of all
you need a proper formula to pull the data from the raw_data sheet and then calculate the difference between that particular cell where the formula resides and the sum of previous cells in that row.
we need two formulas:one for the column B of your value_capture sheet. and the second one for the rest of your table. why? because in the first column you don't calculate the difference between itself and the previous cells, because there aren't any. So there is a little difference in the formula.
FORMULA ONE:(paste in B3 and drag and fill down)
=SUMIFS(raw_data!$C:$C;raw_data!$B:$B;$A3;raw_data!$A:$A;B$2)
FORMULA TWO:(paste in C3 and drag and fill down and to the right)
=IF(SUMIFS(raw_data!$C:$C;raw_data!$B:$B;$A3;raw_data!$A:$A;C$2)-IF(ISNUMBER(B3);SUM($B3:B3);0)>0;SUMIFS(raw_data!$C:$C;raw_data!$B:$B;$A3;raw_data!$A:$A;C$2)-IF(ISNUMBER(B3);SUM($B3:B3);0);0)
As you see in my screenshot for user in cell A3, we have value of 4 for the date 20141120 and the next day the value is 14 but the cell gets the difference, that is 10, and then then next day, the value increases to 16, so the cell value for D3 becomes 2 which is the different of 16 for that day and the sum of previous ones. This continues until today's value which is 24 so the cell gets 7 because the sum of previous ones is 17.
Now that you have your values captured correctly, with respect to the difference with the sum of previous days, it is time to make them fixed and eternal.
For this you need a macro:
Sub saveMyData()
Dim ws As Worksheet
Set ws = ActiveSheet
ws.Range("B3:L18").Copy
ws.Range("B3").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End Sub
So obviously you need to update this range "B3:L18" this is what I have in the example sheet only.
Now this macro, copies and pastes all the values from that range onto itself, so you lose your formulas.So each day, you need to go to *line 21** of the same sheet and get the formula from C21 and paste it on somewhere on row 3 from where you want to continue capturing the new day's data. (you won't need the first formula, because it is only used once in the first column, the first day.)
This was the only way to capture the values using formulas and then save the results of the formulas in their place and go and fetch new data. I couldn't think of any other strategy to make it more automatic, except for writing mova VBA and letting excel go and find where you left the day before and paste the formulas in their right place and repeat the task.
all these formulas are array formulas, so press ctrl+shift+enter to calculate the formulas.
Remember to adjust the formulas to your regional settings, i suppose, by replacing the ";" with ",".
here is the example sheet downloadable from this link
Tell me if you have problems anywhere and don't forget to answer my question in the comments about the way you update your dates in row 2 of value_capture.
The formula that you are looking for is SUMIFS
=SUMIFS([SUM RANGE],[RANGE 1],[VALUE 1],[RANGE 2],[VALUE 2])
SUM RANGE is the column of values that you want to SUM so that is your column C. For Range 1 you want to select the range of IDs. The VALUE 1 will be equal to the value in Column A Row X. For RANGE 2 it will be the Date column. For VALUE 2 it will be the value in the column header.
Put this together and you have something akin to:
=SUMIFS(raw_data!$C:$C,raw_data!$B:$B,$A3,raw_data!$A:$A,B$2)
This would be in cell B3 and you could fill the other cells from there.
If total hits for a day is a rolling count of ALL hits ever then at the end of your equation you need to subtract the sum of the prior days.
For example:
=SUM(B3:B4)
This would only need to be added to subsequent columns (not the first).
So the equation in C3 would be
=SUMIFS(raw_data!$C:$C,raw_data!$B:$B,$A3,raw_data!$A:$A,C$2)-SUM(B$3:C3)
Then in D3 it becomes
=SUMIFS(raw_data!$C:$C,raw_data!$B:$B,$A3,raw_data!$A:$A,D$2)-SUM(B$3:D3)
Try Sumifs formula
=SUMIFS(raw_data!$C:$C,raw_data!$B:$B,$A3,raw_data!$A:$A,B$2)-IF(ISNUMBER(A3),A3,0)