Getpivotdata Pivot location based on a value in another cell. - dynamic

GETPIVOTDATA("Data",{Dynamic reference to another sheet},"Field","Item")
I'm trying to get my formula to be super dynamic. I have 5 - 10 different worksheets with pivot tables on them. I have the rest of the formulas setup to get their "FIELD" and "ITEM" off of a small table of data that can change. I have tried named ranges but again cannot get it to work. The only thing in the getpivot i cannot make dynamic is the location of the pivot table. I was shown the CHOOSE(1,"STRINGS") function, but I do not know how many pivots there will be. I've used the INDIRECT() with vlookups. I'm fresh out of ideas any help welcome.

Using a named range to refer to the pivot table should work. However, make sure the named range only refers to a single cell within the pivot table. If it refers to a range, or the whole table it will not work.
EDIT
If you want to pull the pivottable from another cell, you'll need to use the INDIRECT function
=GETPIVOTDATA("Amount",INDIRECT($Q$2),"Name","Jack","Month","Feb")
Cell $Q$2 can contain either a named range referring to the pivot table or a cell reference. In either event, you will also need to specify the worksheet if you're working across multiple sheets. eg, $Q$2 could contain
Pivots!$A$1

Related

Need VBA script to extend Excel table every week

The problem is as follows: I have several tables in Excel with given number of raws and dynamic number of columns (each week a new column should be added, currently I'm doing it manually). I want to automate it and create a script that will extend every raw range to the next column (namely the range from A2 to C2 should become from A2 to D2), and so on (such that running script N times will result in extending a table to N columns further). By "extending" I mean extending formulas, since each cell in my tables contains any formula. Is there any way to do it via VBA?
I can't just record the corresponding macro because I have now idea how to specify that I don't want to link it with any specific range, but instead always extend just to one column right.
Any help and examples will be very appreciative.
You dont need VBA to do this. Use dynamic defined names and reference them in your formulas. For example, if you add a named range and add this in the refersTo dialog
=OFFSET($A$1,0,0,COUNTA($A:$A),COUNTA($1:$1)
your range will automatically expand from cell A1 (as long as there are no blank cells in column A or Row 1). You can then use that named range in your formulae.
More here http://www.excel-easy.com/examples/dynamic-named-range.html

VBA - How to find frequencies of "x" and "y" in a list

I have a column of names on one page of an excel workbook, I need to find how often each of these names appears in that column and display it on another sheet. For example, the code needs to count "CS" however many times it appears in this column and display it on a separate sheet, then the same with "Grad" and so on. Any tips?
Thanks a lot
That's the primary use of Pivot tables.
Found the solution with a simple function
=COUNTIF(Individual_Stats!D6:D999,"CS")

Worksheet Range Reference - Expands based on data added/removed

Trying to make an array change based on the length of the data added. The data has to be deleted except for the top row starting at A:4 and then pulled via a database that creates rows drilling down to the bottom of the node(s). This can vary from A10:Axxxxx depending on the data in that node.
=AVERAGE(IF((MOD(ROW(Repurchase!E4:E45)+4,6)=0)*(Repurchase!E4:E45)<>0,(MOD(ROW(Repurchase!E4:E45)+4,6)=0)*(Repurchase!E4:E45)))
What I have so far and it works. But of course once the data is deleted and re-pulled
Repurchase!#REF!
shows up and I have to manually add back in A4:Axxxx.
Any help would be appreciated. Can use VBA if needed but was looking for a non-macro worksheet solution.
Replace all references of Repurchase!E4:E45 with,
Repurchase!E4:INDEX(Repurchase!E:E, MATCH(1e99, Repurchase!E:E))
This will create a range from E4 down to the last number in column E. You can delete rows without consequence but the range will dynamically reshape to the new proportions. There can be blank or text within the range. It will always be from E4 to the last number in the column.
If someone suggests the OFFSET function, tell them you would prefer to avoid volatile functions.
If the rows could potentially affect E4 as well, then use the INDEX function to reference both sides of the colon in the range reference.
INDEX(Repurchase!E:E, 4):INDEX(Repurchase!E:E, MATCH(1e99, Repurchase!E:E))

Splitting data between worksheets depending on status of Column A

I have been asked to create a database of volunteers in Excel. The main worksheet (called Data) holds all the information – names, addresses, numbers, reference checks, placements, supervisors, etc. What I am trying to achieve is for the relevant information to be moved from one worksheet to another when the status of the person changes.
There would be 5 categories which the volunteers would fall under (column A labelled ‘Status’)
PROCESSING
ACTIVE
ON HOLD
BARRED
STOPPED/RETIRED
What I want to get is a live database so the information would appear on a relevant worksheet whenever the status on the main spreadsheet changes , but I only want some information to show depending on the category…
Each Worksheet would contain columns A-F from the ‘Data’ worksheet and in addition:
Processing would contain columns X-AE
Active: AF-AW
On Hold: AZ-BC
Barred: AX-AY
Stopped/Retired:- BD-BH
I have searched and searched again but I know nothing about Macros (and my IT department is unable to help) So my question is – is this doable and if so is anyone able to help me?
I hope I am making sense and if not I can email across the dummy database with some made up names to show what it is I am trying to create
You can do this using array formulae. This link shows a simple example which provides the basic formula (explained in detail in the linked article)
=INDEX(range,SMALL(IF(col=value,ROW(range)),ROW(1:1)),COLUMN(A2))
Where range is the range of all your data from your main worksheet and value is the value you want to screen for (this changes for each of your sheets) and col is the column on your main sheet that you want to check the values of. Note it is an array forumla so you have to press control+shift+enter after typing in the formula as explained at the bottom of the link.
You will notice that I have changed the formula to say COLUMN(A2) instead of 2. This is so that you can drag the formula across the columns as well as down the rows. You might need to make this COLUMN(A2)-x where x is an offset because your data don't start in column A.
Note that the same applies for the ROW(1:1) part, if your range doesn't start in row 1 then you will need to offset this by some value as well (i.e. something like ROW(1:1)-y)

#REF! result when using INDEX function in Excel

I am trying to create a couple of reports from data on another Excel worksheet based on the value in a drop down list. I am using the MATCH and INDEX functions and have created Named Ranges of the columns of data. I am able to get the first value I want in the report but none of the others, even though when I debug by evaluating the formula it points to the right cell but still displays #REF! instead of the actual value from the referenced cell.
I'll do my best to make this clear:
In "POST_Data" worksheet I have 4 columns titled Course Name, Course Length, Attendee and Date Attended. Currently I have 33 rows of data (plus the header row) but I need the reports to be dynamic since new data will be added from time to time.
I have created Dynamic Named Ranges of the data using the OFFSET function (e.g. for the Course Name data I have a NameRange called CourseNamesData = OFFSET(POST_Data!$A$2,0,0,COUNTA(POST_Data!$A:$A),1)
In the "DashBoard_and_Data Entry" worksheet I have a two report areas: one to report the Course Name and Date Attended for a specified Attendee (specified by a drop down list in cell C7) and the other report to provide the Attendee Name and Date Attended for a specified Course Name (specified by a drop down list in I7).
In row 8 I report the column that the data belongs to in the POST_Data worksheet
What IS working: When I choose an Attendee from the drop down list in C7, I correctly report the first of the Course Names for this attendee from the data in the POST_Data worksheet. I used the following formula to do so: =INDEX(CourseNamesData,MATCH(C7,AttendeeNamesData,0),B$8)
What is NOT working: The corresponding "Date Attended" data when I use a similar formula as the one that is working. I have: =INDEX(DateAttendedData,MATCH(C7,AttendeeNamesData,0),C$8) but this gives me the #REF! error.
Again, when I try to follow the data that this formula points to, it looks like it is pointing to the correct cell but not showing the result.
Another issue is how to get all the data corresponding to the choice in the drop down and not just the first row. So for example, if I choose Richards, K. from the attendee list and he has attended 4 training courses, I need all 4 to show up, not just the first one.
I appreciate any help or insights on this. If you know of a better way to display the workbook contents, please let me know.
Thanks!
Can you provide a screenshot so that I can better understand the issue?
With regard to your post_data worksheet, you might find it easier to turn the data into a table. You can then point your named range to the column within the table without needing to use the offset function, and your range will update automatically as you add to the table.
I have a entire playlist on my youtube channel devoted to using ranges and tables if you are interested. https://www.youtube.com/playlist?list=PL1nLTDk2QLL9415OPSjIICJs1EeV-HeK3