Where does Excel store the parameters you pass into Range.Group - excel

This has to do with Pivot Tables.
I am trying use VBA (or C#) to get to some data that's stored in the spreadsheet, but I don't know where it is in the object model. I know the data is in the spreadsheet because when I unzip the spreadsheet, I see it in the pivotcache. The following documentation for OpenXML talks about the field in particular:
https://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.rangeproperties%28v=office.14%29.aspx
In the RangeProperties class, see the groupInterval property, in particular.
For instance, the XML shows:
<fieldGroup base="0">
<rangePr startNum="19" endNum="947" groupInterval="656"/>
<groupItems count="4">
<s v="<19"/>
<s v="19-684"/>
<s v="685-1350"/>
<s v=">1351"/>
</groupItems>
</fieldGroup>
But I don't know how to get to this from the Excel object-model at runtime.
The above data represents the entries the user makes in order to group a set of rows in a pivot table. Below are more details on how to get to it.
When you click on Rows of a Pivot Table, you can Group the rows. For instance, let's say you have a thousand rows, but the values range from 1-100. You don't want to see all 1000 rows, just in 10 rows (groups of 100). First group will be a row that aggregates all the rows where the value is between 1-100, the next group for values 100-200, etc.
When you right-click any cell the Row Labels section, and click on the Group item from the context menu, you'll get a small dialog box with "Grouping" in the title bar, and fields:
- Starting at:
- Ending at:
- By:
And there will be a checkbox next to the starting at and ending end fields.
I'll take the defaults, and increment by 100
The equivalent to doing this in VBA (or C# VSTS) is:
Select the cell:
Call the Group() method on the current single-cell selection, eg:
Selection.Range.Group true, true, 100
At this point, the PivotItems associated with the PivotField end up with captions such as "1-100".
Now, if you right-click on the field again and select the Group item, you will get the same dialog box pop-up, with the fields of the dialog box filled in with the previous values you selected for that PivotTable.
However, the information that's used to fill that dialog box doesn't seem to exist anywhere in the object model. I suspect I just don't know where to look.
Does anyone know?
So the basic question in is, when I call the Group method on a single-cell Range object, and pass in various parameters, where are those parameters retained in the object model? I know it's there because Excel itself is able to load it up and it's stored in the spreadsheet.

Related

How to select an item from slicer to show on the chart

I'd like to show in the chart below as title the selection from the slicer. I see two possbile options:
Select the unique row from the table below where the data is from. I've tried Unique function, but it gives me all the unique items from the table, rather than only the selected item
Possible vba code to save the value from the slicer and save in a speficic cell?

ms excel - data validation for 2 drop down list

I'm looking for the solution in excel data validation for 2 drop down list.
When I choose 1st drop down list 2nd drop down list will auto populate the correct value from table. If user choose 2nd drop down list 1st drop down list will auto populate the value also.
Can someone help me on this issue ?
I attach the sample file for my problem.
enter image description here
enter image description here
thanks!
Sample File
Trying to do a two way I don't think is going to work in the way you are trying so I am not surprised the examples you found were for one-way. I am open to being corrected.
You could hack around it for example using two form control listboxes linked to the same cell so a selection in one updates the other.
Then because an item might be out of view listbox underneath have two cells which use the linked cell to index back into the source lists.
In the example above, there are two list boxes from form controls in developer tab (customize ribbon > add developer tab.
Developer tab form control - 2nd from the right
You add two of these in to the sheet.
Right click format control on each one
Set the input range to the range containing your list of values for that listbox and set the linked cell e.g. G1
Ensure that whilst you select different input ranges for each list box, they should have the same linked cell e.g. G1.
Underneath the listboxes put a formula which uses the linked cell G1 to index back into the source lists for each listbox so you can retrieve the selected value and have it visible, in case not visible within listbox.
Example testing:

Word VBA Renaming Drop-Down Form Fields?

I have a set of 6 tables in a password-protected Word document. Each table has a header row, followed by at least one data row. The 6th column of the second (and subsequent) rows has a drop-down form field in it. There is a button above each table that allows the user to add a row to the table. When they do so, the 6th column contains another drop-down.
After the user selects a value in the drop-down and leaves the field, I need to color that cell, based on the selected value. I can set the OnExit value to run a macro I call "HighlightStatus". To get the reference to the cell to change, I am using
Dim ff As Word.FormField
ThisDocument.Unprotect strSheetPassword
Set ff = ThisDocument.FormFields(Selection.Bookmarks(1).Name)
How do I reference the cell that contains this form field?
The other problem is that when I add a row to the table, I need to set the Name of the form field to a unique one, so that I can reference the field that was just updated. But the Name property seems to be read-only.
I took another approach, that basically runs into the same wall. After updating the field, I had the code loop through all the tables and all of the rows, and update the 6th column of each row. The problem is that the screen scrolls down to the end of the document. To get back to where I was, I still need to uniquely reference the correct form field, which I can't do if the field doesn't have a unique name.
Found it. I was chasing my tail for quite a while, but I found that this works.
ThisDocument.Unprotect strSheetPassword
Selection.Shading.BackgroundPatternColor = wdColorLightGreen
ThisDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=strSheetPassword

how to create dynamic filter in text area of spotfire

I want to create a dropdown in text area to filter data in table dynamically.
I have many entries under Filter "Task Description".
But I want to create a dropdown in text area with only below three entries out of all entries.
All - it will show the entire data
Prasanta - this selection will only show Prasanta related rows
Chandan - this selection should only show Chandan related rows.
Is it possible?
the best and simplest way to do this is with a Text Area visualization containing a Property Control. I'll give you a loose outline and you can use the Spotfire help on Property Controls to get more detail.
add a new Property Control of type Drop-down list to a Text Area
create a new Document Property of type string
set the property value through Expressions
the expressions you list here should evaluate to boolean true or false. for example, for Prasanta rows you might use [Task Description] = "Prasanta". the expression for All rows should be blank.
on the Data page of the filtered visualization's Properties, scroll down to Limit data using expression and click Edit...
from the middle pane, double click the name of the Document Property you created in step 2 above
test by selecting different items from the dropdown you created

Dynamic Filters in Excel

I'm using Office 2013, and working on a worksheet in Excel.
My question is, is there a way to create a dynamic filter in Excel?
To explain in more detail, I have a dynamic worksheet, where upon opening the user will get a few drop-down options. After the user has selected one option from each of the drop-downs, the worksheet will display a table of data based on the user's inputs. The user can change their selections from the drop-downs after the table has been displayed, and can also clear their selections. If they clear their selection, the table will disappear.
Now, the first column in the result Table will contain Text values, but can also contain blanks. These values or blanks are all decided based on the user's selections in the previously mentioned drop-downs, which are displayed permanently to the left of the table. I want to add a filter to this first column of the result table (and to the rest of the table with it) such that only the non blank cells are displayed in the table every time the drop-downs are changed.
As I understand your need correct, I can give you this solution:
For getting a better result make your range to Table.
Select Power View from Insert items;
A sheet Power View 1 will added to your workbook;
From right pane select Table1 and its fields;
From Filter pane select as you want for filtering.

Resources