Background color row in ObjectListView filtered by cell value - VB.NET WinForms - objectlistview

Good afternoon,
It's being complicated to solve the problem that i am facing.
I have a ObjectListView filled and need to distinguish the rows that have a specific value in a cell.
So, if the cell as a value of 1 -> yellow row, value of 2 -> orange row, and so on..
I used the default ObjectListView control provided, no code used.
What is the best way to do that?
Thank you!

The documentation on their site includes a very similar example through configuring a handler for the FormatRow event.
OLV Recipes
In my testing, however, I found that the event wasn't firing when I only used the SetObjects() method. I was able to get the event to work correctly after also calling RefreshObjects().
Reviewing their code: SetObjects() never calls PostProcessOneRow(). I'm not sure if this is intentionally left out or a bug.

Related

Keep same value of all merged cells

I don't know why every time I fall in love with a program because I found it very useful at first use, but I end up always struggling of its stupidity after a depth use.
So, my journey begins with the excel function "Merge & Center" that warns me that it will only keep the top left value and delete the others, which is very stupid because I can no longer drag a function in a cell to the others, did no one in this planet suggested that it will be way easier to keep the same value in each merged cells or to put at least a simple checkbox to give the user the option to choose between the two outcomes.
Ok, before I come to this forum I did some research, found a lot of VBA codes, tricks, methods but none gave me the satisfaction that I'm looking for, I concluded that it's impossible to merge and keep values in cells, so can someone please explain to me why Microsoft didn't think of that?
Here is a simple example of what I'm looking for:
enter image description here
As you came to understand, merged cells are Excel's and VBA's worst nightmares! Avoid them (since they also make for terrible datastructures) if you can.
If you must use them and you need a function you can drag down, you'll need to make sure you create a mechanic that can skip certain rows. INDEX() is able to retrieve values with a 2nd parameter that tells the function which row you would like from a given array. If we make sure that this 2nd parameter has a steady incline we can still retrieve the correct values:
Formula in C1:
=INDEX(A:A,ROW()-1-MOD(ROW()-1,3)+1)&B1
After searching all over the internet, I didn't find the perfect solution, so I started learning VBA and I made this beautiful function, it detects if cells are merged or not and if so then it returns the top cell value.
Function Merg(CellRef As Range) As String
Dim MainCell As String
If CellRef.MergeCells Then
MainCell = Left(CellRef.MergeArea.Address, InStr(1,CellRef.MergeArea.Address, ":") - 1)
Else
MainCell = CellRef.Address
End If
Merg = Range(MainCell).Value
End Function
I don't know how to display the code properly on Stackoverflow. It's always a nightmare for me to understand the mechanics, you can visit my same thread on Microsoft Forum.

Return the value in the first non-empty cell in the column directly to the left and going upward

I'm all new to VBA and have mostly been trying to modify code after recording macros, so it's all pretty basic and the approach might not be as elegant as some of the stuff I've seen on here. So here we go.
I have coded (by brute force) my data to be arranged like a CAD design tree view with parent products/assemblies and constituent sub-assemblies/parts.
Column E contains Level 0 top assembly Part Number
Column F contains Level 1 items Part Number
... etc all the way to ...
Column M containing Level 8 items Part Number
As an example, cell G112 contains ASSY1; cells H113 to H134 contain its constituent items.
I would like to display in a new column (i.e. Column O) the value of cell G112 (ASSY1) for each of its constituents. So O113 to O134 would show the value of G112. That would need to be applied to every single level of the assembly.
I'm not sure I'm making much sense do please have a look at the picture linked below, it speaks a thousand words. I've highlighted and colour-coded the result I would like in column O.
ADDENDUM - To clarify things:
I don't know how else to explain my request but to post a simplified version of my original picture.
SIMPLIFIED EXCEL TABLE
.CSV available here WeTransfer
A very useful tool to retrieve VBA code for determined action is the macro recorder, in the ribbon, Developer -> RecordMacro, perform you action and stop recording and then you can check the code generated for the actions you recorded. Its not the cleanest code but you can find there the lines of code for the specific actions you want. Once you step into a one concrete problem with the code you tried, you can then ask for help regarding something more concrete, more than expecting that someone will code that for you.
Anyhow if you want someone to try to solve your problem, you need to post the table with the accessible data instead of the image, for the person whoever tries to approach your problem to have the data available.
Hope that helps
Here's the answer I got from somewhere else if anyone is interested:
Formula in Cell O3:
=IF(C3=0,"N/A , ALREADY TOP LEVEL",INDEX(D$2:D2,AGGREGATE(14,6,(ROW(D$2:D2)-ROW(D$2)+1)/(C$2:C2=C3-1),1)))
Copy/Paste down in every cell in column O

I'm trying to make custom formatting that highlights when a number is more than and less than a specific formula

I work for a brokerage and we profit in the margin. In order to keep these margins at the forefront of everyones mind we want to format it so that if the bid is over our 15% goal it highlights in order to make the broker aware he is outside of the target zone.
In the example below the rate we are charging is $1,000.00 and we want to find a provider for $850.00 or less in order to meet margin. At $851.00 and higher I have the amounts being highlighted, I managed this by putting =sum(A12*0.85) in F and put a conditional formatting into E for =E14>F14, I then hide F to make it look clean.
I am by no means an experienced Docs user so I'm hoping I'm missing an easy fix but my problems are:
That I need to manually enter a lot of this (thousand of lines, always need more), inserting new lines at the bottom of that E14:E23 string does not carry over the F function and causes even a blank cell to highlight orange since the F cell is blank.
I need to have this same process done for many loads, this is one load, the next one might be $2,000.00 and I don't want to manually have to do each one, a simple copy paste method is beyond my ability to figure out.
In column E for example.
Conditional Formatting > New Rule > Use a formula
=IF(AND(A1<>"",E1<>"",E1>=A1*0.85),1,0)

Using COUNTIF/SUMPRODUCT

I have a worksheet that I am trying to make more automated by providing users with updates, however I am having difficulty with getting a formula to work.
I am using a semi-large table (over 32 columns of information, 1,500 rows) but really only want to focus in on 2 columns for this issue. In column C I have the dates that a service order has been requested and in column D I have information that populates when a confirmation of the request is sent (if no request is sent, then it is blank). My hope is to be able to create a message box that alerts when the workbook opens and displays the number of order requests that are within 2 weeks of today that have not yet received a confirmation.
So far, it looks like my best option is to have hidden cells elsewhere that do the heavy lifting with formulas and then to display the values within a messagebox using a Workbook_Open event. I have been able to get a formula to display the number of requests that fit my time window:
=SUMPRODUCT((Table5[Date]>=TODAY())*(Table5[Date]<=TODAY()=14))
And this appears to be capturing the numbers that I need, however I am having difficulty integrating the second component that I need: whether or not a reply was sent. So far, my attempts at including some form of an AND qualifier within the formula has returned an error... I am hoping to be able to quantify within the formula something along the lines (logically) of this:
=IF(Table5[Reply]="" AND Table5[Date]>=TODAY()+14, SUMPRODUCT)
I know that the above won't work, but I am wondering if anyone has any pointers on how to modify this so that it can include both factors?
Many thanks!
Assuming you are looking at dates that are today and up to two weeks in the future, and that the Reply column is blank "" for those dates, then these formula will work for you:
Excel 2007 or higher:
=COUNTIFS(Table5[Date],">="&TODAY(),Table5[Date],"<="&TODAY()+14,Table5[Reply],"")
Backwards compatible:
=SUMPRODUCT(--(Table5[Date]>=TODAY()),--(Table5[Date]<=TODAY()+14),--(Table5[Reply]=""))

How can I make a custom fill handle pattern?

I have a column A3:A71 I wish to populate with values
=COUNTIF(B3:B71,B3)
Where the second argument is incremented with every cell.
Obviously I don't want to copy this function every time, so I was hoping that fill handle would help me. However although it correctly increments the second argument of COUNTIF, it also increments the first one. Even if I correctly populate the first two or three cells in the column A3:A71 with the values
=COUNTIF(B3:B71,B3)
=COUNTIF(B3:B71,B4)
=COUNTIF(B3:B71,B5)
when I drag down from the bottom right corner, I get the function:
=COUNTIF(B6:B74,B6)
=COUNTIF(B6:B74,B7)
=COUNTIF(B6:B74,B8)
=COUNTIF(B9:B77,B9)
=COUNTIF(B9:B77,B10)
=COUNTIF(B9:B77,B11)
Can anybody please tell me how can I force the first argument to stay the same while the second one is increased correctly?
I am using MS Office 2011 for MacOS, but a Windows solution would be just as helpful.
Please try:
=COUNTIF(B$3:B$71,B3)
There are further details at OwenBloggers.com including a table:
and mention that other terms are “absolute cell reference” and “locking”.

Resources