I have a report which gives the current state of an item, and the previous state of an item and I want to display both rows and highlight the differences. For example:
STATUS ORDER# NAME ADDRESS QTY PRICE TOTAL
new 255 Joe 1 Main St 2 5 10
old 255 Joe 1 Main St 4 5 20
new 256 Matt 100 Green Ave 5 5 25
old 256 Matt 65 Blue St 5 5 25
So for order 255 I'd like to highlight the QTY and TOTAL values since they changed.
For order 256, I'd like to highlight the ADDRESS value.
Does anyone know how I can accomplish this?
Thanks a bunch in advance!!
In the textbox properties go to the Fill tab. For fill color enter an expression like this:
=iif(Fields!GroupID.Value=previous(Fields!GroupID.Value)
and Fields!Spouse.Value<>previous(Fields!Spouse.Value)
,Parameters!Color.Value,Nothing)
Change "GroupID" to be your Order# and change the "Color.Value" to the highlight color you want.
Note: This will only highlight the second row when it is different from the first, there is no way to highlight the first row as well because there is no "Next" function, just the Previous function. You can use this to either highlight just the cells that are different or the entire row.
Related
I am running into a problem in VBA in excel.
I am trying to create a participant registration program in excel for a sports tournament. One can add data like the weight, age and name of a participant. And then based on that, The participants are divided into poules named with letters A, B... until Z. I have a table which can sort these poules by letters and then for example only display the participants which are in poule A such as below
Example
Now i want to count the numbers with VBA macros of participants in the poule which is displayed by the sorted table. For example when i sort on poule A it has to return 3 and when i sort on B, it has to return 2.
Determined by the number of participants in a poule the program will print a different poule scheme, depending on the number of participants. (i have this part in VBA)
The problem is when i have a sorted table like below
Example 2
It counts all the participants, and not just the ones in B or any other sorted letter.
I have this:
Sub Count()
Dim nRows As Integer
nRows = Range(Range("A18"), Range("A18").End(xlDown)).Rows.Count
MsgBox (nRows)
End Sub
This works well if you sort A, but when you sort any other letter, it counts All the table until that letter. Eg. when you sort B, it displays 5 (Number of A + B).
I have looked on the internet for a really long time to find a solution but without succes.
I hope my question is clear and that somebody can help me.
I am assuming that you are using worksheet functions. Use Subtotal when working with filtered data.
These parameters evaluate all cells visible or hidden
1 AVERAGE
2 COUNT
3 COUNTA
4 MAX
5 MIN
6 PRODUCT
7 STDEV
8 STDEVP
9 SUM
10 VAR
11 VARP
These parameters evaluate only visible cells
101 AVERAGE
102 COUNT
103 COUNTA
104 MAX
105 MIN
106 PRODUCT
107 STDEV
108 STDEVP
109 SUM
110 VAR
111 VARP
The code does work now, except that it only counts the first letters it encounters.
So when the first column for the poules is for example A A A E A A B B E.
And i sort to A and use the count function, it only returns a value of 3 and not of 5 (because there are 5 A's)
When I sort the table to A, it looks like this (column number, poule value):
14 A
15 A
16 A
18 A
19 A
And it returns just a count of 3, have you maybe got any fixes for that problem as well?
Pictures:
sorted tabel to E
Table
Range.SpecialCells will return a range of only visible cells.
Dim rSource As Range
Dim rVisibleCells
Set rSource = Range(Range("A2"), Range("A2").End(xlDown))
Set rVisibleCells = rSource.SpecialCells(xlCellTypeVisible)
MsgBox rVisibleCells.Rows.Count
I'm trying to color and frame a column in data. There are blank rows inside. I only want to color the cells with value. The data position might change, so I want to use an input box to color and frame .
The data will be like this. The select range would be column B.
1 A
2 B
3
4 A
5 B
6
7 A
8 B
9
10 A
11 B
12
13 A
14 B
15
16 A
17 B
18
19 A
20 B
21
22 A
23 B
You don't necessarily need VBA - you could use Conditional Formatting. Highlight the entire column B, then go to "Conditional Formatting" under Home tab. Click "New Rule" and choose the last one in the list, "Use a formula to determine which cells to format.", enter this in the box =$B1<>"". Then click "Format" and go to "Fill" - choose the color you want, and hit "OK" and "OK". That should do it!
Edit: Ah, about the input box - can you expand on what you want to do with that? What do you mean by using it to "color and frame"?
I have a table that has 20 rows and the table un-hides the amount of rows specified in the cell above my table. so if I put in 5 into the cell, 5 of the 20 rows will be un-hidden.
So now I would like to get the MAX of the say 5 cells that are now unhidden. How would I do this?
=SUBTOTAL(104,RANGE)
104 will give you the max of the unhidden cells. If you replace 104 with 4 it will operate as the normal MAX function UNLESS you are filtering the rows using the built in Excel table function.
Perhaps
=SUBTOTAL(104,your_range)
I have a table in Excel with dates and values. Every day there were a number of different values.
I want to summarize how many of each value there were every day.
Example:
From this
Date Value
10/1 Blue
10/1 Blue
10/1 Red
11/1 Blue
11/1 Blue
I want to get a new table with something like this:
10/1 11/1
Blue 2 2
Red 1 0
I'm convinced this is possible to do in VBA/Excel. Does anyone have any ideas?
Assuming the first table is in A1 and the second in E1, you could use a formula in F2 like:
=SUM(($A$2:$A$6=F$1)*($B$2:$B$6=$E2))
This is an array formula so you need to validate it by pressing CTRL+SHIFT+ENTER.
A2:A6 is the range with the dates, B2:B6 the range with the colors in your first table.
The first part of the formula says: Retain records where the value in column A is 10/1 ( = F1).
The second part says : Retain records where the value in column B is Blue ( = E2).
The '*' is equivalent to AND.
More about it here: Multiple conditions in excel 2002
The solution was, just as Alex K said, to use the Privot Table function included in Excel.
Thanks for your help!
I have an application that keeps rent periods of a parking lot. I have a SQL database with this information:
idLot dateFrom dateTo
------------------------------------------
1 01/03/2011 30/07/2011
2 01/01/2011 30/05/2011
3 01/02/2011 30/07/2011
6 01/02/2011 30/06/2011
And I need to display the information like the image below.
1
I cannot achive the goal with Excel or Crystal Reports. I also use ComponentOne FlexGrid. Any ideas?
Thanks in advance.
It's not the prettiest option, but you can do this in Excel using the Sumproduct() function. In the screenshot below, the sumproduct goes through each line of your datatable and does 3 things (the selected cell is B17 by the way):
It determines whether each row has the idlot it is looking for (evaluates to true/false)
It determines whether DataFrom is <= the column of your display table (evaluates to true/false)
It determines whether DataTo is >= the column of your display table (evaluates to true/false).
This results in a 0 or 1 in each cell of your display table. This is close, but not exactly what you're looking for. I then added some conditional formatting:
If the result of the equation was 0, then the cell's font is white.
If the result of the equation was 1, then cell's font and background are both green.
When you apply the conditional formatting to the entire graph, you get the last 2 rows, which is green for occupied and white for unoccupied.
The only remaining problem is how to account for a changing number of rows in your table. This can be solved by just setting the ranges in your equation to a very high number.