Custom Code to repeat static row on a new group instance only - vba

I have a report where the end user has an input section strictly for in person use. It is a row where they choose "yes" or "no", basically. The issue is that this section is based per group. So, for example, each group is a sales order, that order may have many pages, this "yes/no" section requirement is to only show on the first page of each group.
Note, I have tried to used the Previous function to hide the row, using a field a field from the header section, no luck there. I'm not a programmer by trade and more over don't have experience in VBA
I have exhausted my searches on Google and it doesn't seem like anyone has done this before. It may not be possible because in the row the fields are static texts and aren't referenced from a real dataset.
Appreciate any input or work around that could work, or solidify the fact this isn't possible in SSRS

Related

How do I prevent unlocked cells from being selected/editable? (VBA)

I have a very specific question that I am looking for help in answering. I have been researching for hours and I feel like I am not able to find what I am looking for. Below is a quick overview of the criteria that my document must follow:
I am using Excel 2013
I will just be using rows for data input (instead of an excel object
table).
The very top/first row will act as my "column header".
This top row will have AutoFilter enabled.
THE DOCUMENT MUST BE PROTECTED (a must-have)!
I will be using VBA code
Now, the final issue I am having with finishing this document are the last two criteria points that I must have:
The first/top row (column headers) must NOT BE EDITABLE.
Each column must be able to SORT AND FILTER.
Now, in a perfect world, I would just "Lock Cells" for the entire first row that acts as my column headers and when I protect the worksheet I would make sure to check the "Sort" and "Use AutoFilter" boxes.
However, this option does not work because there seems to be an issue when I try to sort the data. If I just filter the data there is no problem, but when I try to sort a column in ascending/descending order I will get an error informing me that I can't sort locked cells while in Protected mode. This is because when excel uses the Sort function, it counts the header as part of the data that is being sorted (I found this out through my research) even though I really just want the data below it to be sorted.
I have been trying to brainstorm on how to get past this issue as well as researching different methods, and I am having trouble coming to a final conclusion. However I have narrowed it down to 2 possible solutions:
I want to be able to keep the cells in the first row officially unlocked to allow the AutoFilter's sort command to work as intended, but make it "behave" like the cells are locked when a user tries to make changes to it (AKA, make the entire row un-editable or un-selectable).
The other option would be to keep the first row locked but somehow have an event in VBA that can tell when a user tries to "Sort" the column, which will then temporarily unprotect the worksheet, follow through with the intended sort command, then protect the worksheet again (apparently though, upon my research there is no such event that can trigger off the AutoFilter's sort command alone).
These 2 solutions are the most logical I can think of based off my research, but if someone out there is an Excel genius and knows another way I am open to suggestions.
Thanks in advance for your help/suggestions,
Travo
Consider using two header rows. The top row would be protected and the second row would facilitate filtering and sorting of the data in rows 3 and below.

Last() function in SSRS. How do I define a group?

My end goal is only showing a field if the row is the last of a GROUP.
I think that I can accomplish this by saying if the row number is the last of the group, show the row. How do I specify that in the visibility expression?
Currently I am trying this:
=IIF((RowNumber("LINE_No") = Count("LINE_NO)), True, False)
I know I'm off. What I have is 3 LINE_NOs corresponding to different groups. So I want the field to show at the last line of each group, I just can't distinguish it. Let me know if you need more pictures or context.
Really, I just don't know how to define that group, as opposed to the entire data set.
I don't know why you are stuck with this requeriment, seeing this and another related questions you posted this is what a I get you need.
I've recreated your scenario using this dataset:
I've added a tablix with these data arrangement.
It will produce the note at the very end of every Line group.
Let me know if this helps you.

Limit PivotTable Filter based on another filter

I have a pivot table with multiple filters, such as:
Site: select one of the sites
Supervisor: shows all supervisors, regardless of site
Currently, the Supervisor filter shows all the available options from the data set. I want it to only display the supervisor names that match the selected site. I'm trying to put together an automated solution that will update as users select the options they need within the filters (to see their site and individual teams, for example). I'm trying to automate this, so it will always be current as supervisors are added/removed from the data set.
I'm pretty sure automating this is a VBA issue, but I'm pretty new to using VBA, so I'm not sure where to start.
Seeing as I'm new and do not have enough rep to comment I will just give you an answer and if it's not what you're looking for I will remove it.
I don't believe this is a VBA issue. In the pivot table Field List you will want to set Supervisor to be filtered by clicking the little downward arrow beside the field name within the "Choose fields to add to report" box. That way when you select a site you can then filter out any of the supervisors that don't belong there.

Turning Off Grouping In ObjectListView Turns Of Sorting

I am struggling to find information on a lot of small issues I'm starting to come across since recently integrating the ObjectListView into my application. I must admit, I love the control and it takes a lot of work away from me by having the control pretty much do everything that I need.
However, amongst a few issues that I've come across thus far, one is the fact that if I turn off grouping for individual columns it no longer allows me to sort these columns.
For example, my ListView control has an ID, Summary, Location, etc., etc. I currently run grouping on the ID because I attach a unique footer against every ID and it looks good. But, when I click on Summary, or Location it then groups all items by Summary or Location and therefore I end up with the group header but no footer anymore because the footer no longer corresponds with the ID.
What I want to achieve is to allow the user to click on any other column, but still maintain the group by ID and thus keep the footer against each item. I only want the items to sort, not group, but as mentioned, when I turn off the grouping against each column, it turns off the sort function.
UPDATE
Basically, looking at the screenshot below, I want to be able to click on the Priority Column Header (for example) to sort the list of object by Priority, but still maintain the Group By Ticket (with the Group Footer details). And basically be able to click on any Column header to sort the list but keeping the grouping by Ticket.
I have intercepted the OLV_BeforeCreatingGroups event to add:
e.Parameters.GroupByColumn = Ticket_ID
This now seems to maintain my grouping by Ticket no matter what Column header I click on, but I now loose the sort functionality.
Try setting AlwaysGroupByColumn to be the TicketId column. That will do the trick :)
Second attempt:
Thanks for the screenshot. I think I understand what you want. You are hoping that clicking on the header will sort the groups themselves. That's not the default behaviour, which is to sort the rows within each group.
To do what you are asking:
Listen for BeforeCreatingGroups event and fill in the GroupComparer property on the event argument block. This comparer controls the ordering of the groups.
The default group order is based on OLVGroup.SortValue. So you could install a GroupFormatter delegate and change the SortValue for each group so they are ordered in the manner you want.
In either case, you will need to use PrimarySort and PrimarySortOrder to know which column the user last clicked.

Determining whether VBA is necessary in Excel, or if a pivot chart/table can suffice

I wish that I had a more precisely descriptive title for this question, but I am not very knowledgeable with Excel spreadsheets or VBA (I'm primarily a Java developer, and don't play much in the Microsoft world).
I'm trying to use an Excel spreadsheet to accomplish something. I need to determine whether I can get there with a PivotTable, PivotChart, or some other built-in functionality... or whether I need to go down the path of writing custom VBA code (or maybe using another platform altogether).
The purpose of the spreadsheet is to help create schedules for an organization (a Toastmasters club). This organization has a roster of members, it meets weekly, and various members are assigned to various roles in a given meeting.
My spreadsheet looks like this:
First Tab
One column... a list of names representing the membership roster.
Second Tab
Each row represents a past meeting date. There are columns for each role, and the cells are to be populated with who served that role on that date. I use Data Validation to have the first tab's roster available inside each cell as a pulldown.
Third Tab (maybe multiple tabs?)
Here's the point of the whole thing. For each of the possible meeting roles, I would like to see which members are the most "overdue" to be assigned for that role. Basically, I want a list of all the club members, sorted in order of how long it's been since they last served that role. People who have never served in that role would be sorted at the top of the list.
Is that third tab data something that can be accomplished with a PivotTable, etc... or am I misunderstanding the purposes and limitations of those tools?
I found a way you can do this with pivot tableS - one per role. It's a bit dubious whether you should, but depends how many roles you have really. I made it work using 2 as a sample, here's the gist:
You have an (Excel) table containing Names
You have an (Excel) table containing Meeting Date, RoleA, RoleB... (I used Chair and Secretary as nominal examples), these cells contain the name of the person taking that role
You then create a Pivot Table for each role (Insert --> Pivot Table). The fields to use are: Row Labels - whichever role you're analysing; Values - Meeting Date
You then change the result type by going into Field Settings, and change it to Minimum. Note that only people who have had that role will show up here.
Repeat this for each role.
Go back to your table of names, and add a column for each role to show when they last held the role. The formula for this is the rather unwieldy:
=IFERROR(GETPIVOTDATA("Meeting Date",Chair!$A$3,"Chair",People[[#This Row],[Name]]),0)
The GETPIVOTDATA will error if they haven't had that role, so I'm replacing errors with 0 (an arbitrary low number)
You can then identify the person most overdue for the role using:
=OFFSET(People[[#Headers],[Name]],MATCH(MIN(People[LastChair]),People[LastChair],0),0)
If there is a tie, the person who appears first in your list of names will be given here.
Hope that makes some semblance of sense, ask away if any questions
My first instinct is to move you to Access where you can SQL query to your heart's content, but I'm sure this can be done in Access without any custom coding.
PivotTables may work, but I avoid them for several reasons (hard to describe to casual users, doesn't update automatically, hard to format, etc.), so here is something using just Excel's built-in cell functions.
Check out vlookup() and countif() on http://www.techonthenet.com/excel/formulas/index.php. (The built-in help files work too. I just like this site more)
In the image below, I have simulated your Tab2 and Tab3. Tab2 is purely data with no equations. Vlookup() requires that this table be sorted by Date Descending and with the date column on the far right.
Tab3 counts both the # times each person has served in that role and when they last worked that position.
The formula in cell C13 is =COUNTIF($B3:$B8,$B13). i.e. it counts the number of times that "Abe" appears in the Chairperson column of Tab2.
The formula in cell D13 is =IF(C13>0,VLOOKUP($B13,$B$2:$D$8,3,FALSE),"-"). i.e. if that person ever served in that role, then it finds the most recent date.
The formulas for security are almost the same. The "Last Served" column is now =IF(E13>0,VLOOKUP($B13,$C$2:$D$8,2,FALSE),"-"). The ranges need to be renamed here to satisfy the needs of the Vlookup function (a SQL query would be really convenient here, but Excel doesn't allow that)
It's hard to define if someone is 'overdue' because some people will argue that "Last Served" is more important than the "# Times Served" and others will argue the exact opposite. I suggest looking at both columns and just talking it over.