Index and Match Excel - vba

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.

Related

Master Spreadsheet, Referenced by presentation spreadsheet - potentially hard?

I just started a project for a client company and they're needing something kind of unrelated, I'm hoping to get some help with that here.
The situation is this. I have a continually updating "master" spreadsheet located at \ServerA\Folder1\Folder2\MasterSpreadsheet.xlsx. This houses dates ascending left to right on row 219. The dates are ascending(Format mm/dd/yyyy), but not sequential(they skip a few days here and there). The Quantity(row 220) corresponds with dates(row 219). These both start on Column C.
FIRST "Set" of dates/qty on row 219/220 Column C.
SECOND "Set" of dates/qty on row 224/225 Column C.
I then have a "Presentation" spreadsheet that will reference the master.
Dates are ascending top to bottom (range 4/25/18 - 12/31/18) in column F and ARE SEQUENTIAL, qty in column G, starting row 9.
So basically what i need is an excel statement that will do this, in whatever fashion is needed.
If the FIRST AND SECOND sets' dates in the date row in MASTER match(could be in column C, all the way to column CZ), the quantities for them both will be added and placed into the correct row (Dates match) in the PRESENTATION spreadsheet.
If the FIRST AND SECOND sets' dates in the date row in MASTER DO NOT match, then they just go to their respective dates on the PRESENTATION spreadsheet.
I hope that was clear enough! Sorry to ask, i can do the rest but this really has me stumped.
Thank you very much!!!!!
I do not understand why you differentiate match or not match for master sets date.
I suggest in sheet PRESENTATION from cell G9 :
=SUMIF(MASTER!$C$219:$CZ$219,PRESENTATION!F9,MASTER!$C$220:$CZ$220)+SUMIF(MASTER!$C$224:$CZ$224,PRESENTATION!F9,MASTER!$C$225:$CZ$225)

Sum unordered data across multiple sheets

I think sumproduct sumifs indirect is what I need but I fail to see how to construct it;(
I have a workbook for logging volunteer hours.
I'm summing up the monthly hours (12 sheets/tables) to FY Totals sheet/table with hours by volunteer. So the sheet/table that I want to use the formula in is FY TOTALS
The workbook consists of 14 sheets:
sheet(VOLUNTEERS) has a table(tbl_volunteers) It contains data about the volunteer and the 1st 3 columns are duplicated on all 13 sheets (12 monthly and 1 FY totals)
A5[Status] B5[LastName] C5[Firstname]
The Month sheets have the above fields followed by 5 categories with hours per category for each volunteer
The sheet/table FY Totals is identical to Monthly, but I want the categories to sum all 12 months for each volunteer.
So I need to match criteria of [LastName][FirstName] and sum values in [category]D:I
I can send a copy of the file, but not load images here;(
You could use multiple consolidated ranges.
Notice that I have four different ranges. These could have been in different worksheets and the names aren't necessarily in the same order. A pivot table has been created that sums the hours worked for each person as requested. In this example, they just happen to be the same.
How?
Press Alt+D+P (windows) or cmd+alt+P (mac)
Select multiple consolidated ranges, then Next
Select Create a single page field for me, then Next
Add each of your ranges one by one, then Finish
Update
There's so much more you can do with PivotTables, as per your comments -- you can separate out data by creating your own page fields. Do this instead of step 3 above
Select I will create the page fields, then Next
For each range you select and add, click '1' page field and type the description of that data, for example 2016 Data, or 2017 Data
(Optional) Your fields will automatically be put into the report filter field. You might want to drag it into Row Labels field (below Row) to get the view below
You can then see the split of the different fields you used in your PivotTable - in yellow I have my 2016 data and you can see it's been split out in the PivotTable.

Dynamic reference in excel formula

I have the following array formula which works for what I want to do but I'm trying to change the formula when a user selects a value.
=INDEX($A$2:$B$70,SMALL(IF($A$2:$B$70=$A$121,ROW($A$2:$B$70)),ROW(1:1))-1,1)
It's used for a monthly report and the user will choose from a drop down the day of the month, e.g 1,2,3 - 31.
So if the user selects 1 from the drop down menu I want the formula to use the above formula.
If they select 2 for example I want the formula to move over a column so it would change to
=INDEX($A$2:$C$70,SMALL(IF($A$2:$C$70=$A$121,ROW($A$2:$C$70)),ROW(1:1))-1,1)
and so on moving over a column at a time.
It this possible at all or can it even be done without VBA?
I have an example of what I want done on the following link
https://docs.google.com/spreadsheets/d/1MDOzoQxYLgW-UOyljZsMwSu8zyAB7O2k1V-bTNP5_F0/edit?usp=sharing
All the data is on the first tab called staff. Each employee has a row and the duty assigned under the corresponding day column.
On the Roster tab it summarises each day. So what I am trying to get to happen is when you choose the day of the month (or preferably the actual date) the sheet changes to reflect the data.
At the moment the code I have working does for just Day 1 because the column references are coded into the formula. I was hoping to somehow choose 6 for example from the drop down and then the formula will map chosen day to the corresponding range in the raw data and update the formula and change the formula from Staff!$A$2:$B$68 to Staff!$A$2:$G$68.
If the formula finds no more entries if shows #NUM! but I intended to use the function ISERROR() to replace #NUM! with "".
This is what I'm trying to achieve it if makes sense?
There are a few issues here/ You are returning the value from column A so the first range can be $A$2:$A$70 and that means you don't need the 1 to specify the column_num. The IF statement was covering A2:C70 when you really only want either B2:70 or C2:C70 depending on the 1 or 2.
Assuming that A122 has either a 1 or 2 in it then,
=INDEX($A$2:$A$70, SMALL(IF(INDEX($B$2:$C$70, 0, $A$122) = $A$121, ROW($1:$69)), ROW(1:1)))
Standard non-array alternative,
=INDEX($A$2:$A$70, SMALL(INDEX(ROW($1:$69)+(INDEX($B$2:$C$70, 0, $A$122) <> $A$121)*1E+99,, ), ROW(1:1)))

Sumproduct dates

I have a spreadsheet worksheet called “ISO Procedure Master List” where the date a procedure is requested is in column G (Format m/dd/yyyy).
In column H the date the procedure is completed is entered. Column H uses the same date format but may contain blanks (procedure not completed yet).
There are currently 67 rows of information in the spreadsheet that span from 2011 to 2015 and that number will continue to grow.
QUESTION, I would like to get the average time (in days) it took from a procedure request (column G) to the completion of procedure (column H) for all of the procedures requested in a given year.
In other words the average (in days) time it took to complete procedures in a given year.
This answer will be in a cell C34 in the same workbook but a different worksheet called “ISO Matrix”. (This information probably does not matter but I thought I would add I just in case)
I have tried several Sumproduct variations with no success.
Assumptions:
Dates in columns G and H are dates, not text string,
Data start in row 2, using row 1 for headings.
For convenience, I assume you have named the ranges you wish to average requestDate and completeDate
You wish do ommit the rows where the procedure is not finished from the average calculation.
After naming your ranges, input the following formula into C34 on "ISO Matrix" tab:
=AVERAGE(IF(completeDate<>"";completeDate-requestDate))
This is an array formula, so when normally pressing enter, remember to press CTRL+SHIFT+ENTER instead. When highlighting the cell, it will then look like this:
{=AVERAGE(IF(completeDate<>"";completeDate-requestDate))}
NOTE: My language pack uses ; as formula separator, so if you language uses , instead, change the formula to:
=AVERAGE(IF(completeDate<>"",completeDate-requestDate))
EDIT: So, I didn't catch that you needed to average by year. In line with my recent formula, it could be update to suit your request.
=AVERAGE(IF(completeDate<>"";IF(YEAR(requestDate)=A15;completeDate-requestDate)))
where A15 holds the year you are interested in. I tried it with an AND in the first IF instead of two IFs, but that did not seem to work. Mind you, you might still need to change ; to , and you also need CTRL+SHIFT+ENTER for this one.
You could also add the code below, to handle the case where you test a year that is not present in the list:
=IFERROR(AVERAGE(IF(completeDate<>"";IF(YEAR(requestDate)=A15;completeDate-requestDate)));"No such year")
...or something like that

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)