I need to print a PDF output for each name in the page field list (highlighted in the image below). It shouldn't be the best approach, but I thought I'd get the list with all the available names and go filtering with a vba loop.
For Each Item In pvt.PivotFields("[LANC].[NAME].[NAME]").VisibleItemsList
Debug.Print Item
Next
The problem that only works by selecting n-1 from the n elements in the list. If you select all, the field is set to "all" and VisibleItemsList returns an empty element.
I have a Combobox on a UserForm populated with multiple values.
Based on user input I keep redefining the Combobox to less and less entries in the DropDown.
At the point where there is only one value left in the Combo Dropdown, how do I get that value to appear in the Combobox Text field?
You can access ComboBox values via the .List property.
expression.List(pvargIndex, pvargColumn)
keep in mind, the pvargIndex (row) and pvargColumn (column) do begin with the index 0.
So to the access the first element, you would use ComboBox.List(0, 0) = something
I think I've found my own solution.
The .listindex, after the fact, always comes up as -1 but each time I re-filter the combobox elements I can keep overwriting a variable within the AddItem loop with what the Combobox value is. When my count of elements = 1 then the value stored in that variable will be the last, and only, value that I was looking for.
Here's a quick summary of what I am trying to do:
I'm trying to set up an Excel workbook that will allow users to paste the results of a SQL query into a RawData worksheet and have multiple other worksheets then grab that data and display it in various formats (graphs, charts, etc.).
This particular formula that I'm trying to write is supposed to look at a certain column in RawData, compare the number listed there to a "key" in the Key worksheet, and then return the text equivalent to the ID displayed in RawData in a new worksheet called StylizedData
For example, if RawData lists 1, then StylizedData will list "Configuration" because 1 is associated with "Configuration" in the Key.
Here is the formula:
=IF(RawData!F60=Key!$C$2,Key!$D$2,
IF(RawData!F60=Key!$C$3,Key!$D$3,
IF(RawData!F60=Key!$C$4,Key!$D$4,
IF(RawData!F60=Key!$C$5,Key!$D$5,
IF(RawData!F60=Key!$C$6,Key!$D$6,
IF(RawData!F60=Key!$C$7,Key!$D$7,
IF(RawData!F60=Key!$C$8,Key!$D$8,
IF(RawData!F60=Key!$C$9,Key!$D$9,
IF(RawData!F60=Key!$C$10,Key!$D$10,
IF(RawData!F60=Key!$C$11,Key!$D$11,
IF(RawData!F60=Key!$C$12,Key!$D$12,
IF(RawData!F60=Key!$C$13,Key!$D$13,
IF(RawData!F60=Key!$C$14,Key!$D$14,
IF(RawData!F60=Key!$C$15,Key!$D$15,
IF(RawData!F60=Key!$C$16,Key!$D$16,
IF(RawData!F60=Key!$C$17,Key!$D$17,
IF(RawData!F60=Key!$C$18,Key!$D$18,
IF(RawData!F60=Key!$C$19,Key!$D$19,
IF(RawData!F60=Key!$C$20,Key!$D$20,
IF(RawData!F60="",""))))))))))))))))))))
That whole process is working correctly all the way up until I get to the point where a row in RawData is empty. When the row is empty, it is displaying "No Subcategory", which is the text equivalent of Key!$C$2 and is contained in Key!$D$2. I'm wanting it to display nothing, which I'm trying to accomplish with that last snippet (IF(RawData!F60="","")).
Can anyone help me out here?
Thanks in advance.
Try,
=iferror(vlookup(RawData!F60, Key!$C$2:$D$20, 2, false), text(,))
=if(iserror(vlookup(RawData!F60,KeyArray,2,0)),"",vlookup(RawData!F60,KeyArray,2,0)
If the lookup value isn't found the cell gets a "" value. Otherwise it will search for the value contained in F60 in your key array and return the value two cells to the right.
With Vlookup() your array/range must have the values you are searching for in the first column. Your column/array must also include the column of values you want to return. For instance you would probably use something like $C$2:$D$20 for your key array. It also helps if your key values in your key array are sorted.
Good luck!
Background info:
Column A = Last Names,
Column B = First Names,
Column C = a drop down box with a list of options determining whether
the person listed in A1B1 has a certain status(active rep,
disaffiliated, etc) there are 5 or 6
In column D, I would like an input box to prompt the user depending on what the answer choice is in Column C. If for example 'C2' = "Active Rep", I'd like the prompt to ask for a date mmddyy, or if they hit cancel to allow them to enter something manually (text)
If 'C2' = Disaffiliated, I would like to to provide a drop down box giving them a list of options from the control page.
This would need to happen for each named person in Column A for which there are about 100
Is this possible or am I thinking too big and just need to simplify things.
You can use the WorkSheet_Change() event to check what was input and do a Select Case statement to handle each selection differently.
I am looking for help on filtering multiple values in one cell delimited by a comma.
For example I have a spreadsheet with the following data:
Column A (Risk) Column B (Risk Mitigation)
Risk A Requirement1, Requirement2
Risk B Requirement2, Requirement6, Requirement7
Risk C Requirement1, Requirement3, Requirement9
When I filter on the 'Requirement Mitigation' Column I would like to see check boxes for the following:
Requirement1
Requirement2
Requirement3
Requirement4
Requirement5
...
Requirement9
So for my example when I only check the Requirement 1 filter box, only 'Risk A' and 'Risk C' rows would be displayed
Currently when I filter it does by the unique cell value, which gives me
Requirement1, Requirement2
Requirement2, Requirement6, Requirement7
Requirement1, Requirement3, Requirement9
Please note that above is just an example and I have thousand of individual requirements, so it would not be as simple as having one column per requirement.
I open to any suggestions including creating vbscripts.
Any help would be greatly appreciated.
This will be tricky.
First you'll need to create a form that will contain a list box and populate that list box with the Requirements you have in their correct syntax.
Then you'll need to create a loop that will go through every cell in a column and save each of them to a string, you could make a one dimensional string array to save them all in that as well.
Then you'll need a loop that will go through each string and use the split function to seperate the strings with a delimeter, you'll need to set your delimiter to ", " to ensure it seperates the strings at the commas.
Then you'll need a loop that will run after you've made your selection from the listbox in your form. this loop will go through every string in your 2D array and check if it contains any of the requirements in your listbox. If it is not, run the code: Range("B" & x).EntireRow.Hidden = True where x is the row, you can use one of the variables in your loop for this.
If you need more specific information that this I may need to see what you've already done, it is possible as well to use this method to automatically populate the list box in your form.