Conditional Formatting Rule: Highlight Row when Cell Value in X Column Begins With - excel

I'm trying to highlight rows in my spreadsheet where cell values in Column B start with qr.
I tried following ExcelJet's example "Highlight cells that begin with," but this method will ONLY highlight cells. It will also highlight other cells in other columns where cell's value (string) begins with qr.
I did come up with a small googled solution.
Created a rule within Conditional Formatting and used this.
=SEARCH("qr",CONCATENATE($A2, $B2, $C2, $D2,$E2,$F2,$G2))=1
The problem with this solution is it will concatenate the rows in which qr exists and highlight them. It will also do this to rows in which a cell's value other than in column B starts with qr.
May I get some help with this please?
I wasn't able to produce a solution table for my question, but the solution would be the same table with ROW 2 AND ROW 5 highlighted only. The current rule I'm applying will highlight ROW 2,3, and 5 and concatenate their cells.
|---|---------------------|------------------|---------------------|
| | A | B | C |
|---|---------------------|------------------|---------------------|
| 1 | Full Name | Username | Email Address |
|---|---------------------|------------------|---------------------|
| 2 | Mario | qrmrincon | mrodrigez#yahoo.com |
|---|---------------------|------------------|---------------------|
| 3 | Sofia | sgrahama3 | recio1#hotmail.com |
|---|---------------------|------------------|---------------------|
| 4 | Qrig | grecio1 | recio1#msn.com |
|---|---------------------|------------------|---------------------|
| 5 | Mora | qrmturner2 | turner2#aol.com |
|---|---------------------|------------------|---------------------|

For the Conditional Formatting formula, just use:
=LEFT($B2,2)="qr"
Then for the "Applies to" range, put:
=$A$2:$C$100
(Adjust that last row based on the data)
And just format as you wish (a Fill is likely what you want).

Related

How to do multi-column match in Excel

I have a spreadsheet that looks like this:
A B C D
------------------------------------
1 | Yes | No | | | |
2 | 1 | 1 | 0 | 1 | 0 |
------------------------------------
------------------------------------
12| Yes | No | | Yes | Yes |
13| Yes | Yes | No | No | |
14| Yes | No | | No | Yes |
15| No | Yes | No | No | |
...
I want to fill the cells in Row 2 with a 1 or 0 depending on several criteria. The value should be 1 if all of the following are met (using cell D2 as a reference):
All previous values in Row 1 should match at least one entry in the table starting at D12. For cell D2, this means A1:C1 should exactly match columns A:C in at least one row of the table.
For any of the matching rows from #1, there should be a non-empty value in the same column as the cell being evaluated. So cell D2 would look for a non-empty value in Column D of any rows that match the criteria in #1.
If either of these conditions fails, the cell value should be 0. In Cell D2 we have a value of 1 because the algorithm finds a match in rows 12 and 14 and a non-empty cell in D12 and D14.
I'll need to be able to apply this dynamically across several columns so I'm trying to avoid writing a column-specific function. I realize I could probably write a UDF to perform this, but I wanted to avoid going that route if possible.
Because this was a challenge I had a go at it and came up with
=SIGN(SUM(--(MMULT(($A1:A1=$A12:A15)*(B12:B15<>""),TRANSPOSE(COLUMN($A12:A15)^0))=COLUMNS($A1:A1))))
to be entered in B2 and pulled across. This has to be entered as an array formula using CtrlShiftEnter
A2 I think is just
=sign(counta(a12:a15))
because it will be 1 unless the whole column is empty.
I'm not sure there's a complete answer to your problem as stated without a UDF, but I'd question the method a bit and say "why complicate with 'AND this column isn't blank (but could be any other value)?"
Why not just look for a row match from that field backward? Seems to me it would just shift things by a column, and in fact, this is exactly what you're doing in A2 anyway, since there's nothing before A. So matching on duplicate rows for example, D2 would contain basically the same information as your example has in C2.
To look for duplicates across fields, you could use something like this formula that would go in C2: =IF(SUMPRODUCT((A3:A15=A1)*1,(B3:B15=B1)*1,(C3:C15=C1)*1)>1,1,0)
In D2, you'd copy that formula and add (D3:D15=D1)*1, etc.

How can I conditionally VLOOKUP in Excel?

Suppose I have the table I need to VLOOKUP() through:
id | indicator | value
-----------------------
1 | a | abc
1 | b | def
1 | c | ghi
2 | a | bbc
2 | b | bef
3 | a | aef
There is a table where I need to attach only values with indicator equal to a:
id | value
----------
1 | abc
2 | bbc
3 | aef
Something like conditional VLOOKUP() is required. What is the elegant way to do it?
You can do multiple criteria INDEX-MATCH to achieve this:
=INDEX($C$1:$C$6,MATCH($E1&"a",$A$1:$A$6&$B$1:$B$6,0))
This is array formula and it works by hitting Ctrl+Shift+Enter.
Also, I assumed that your Lookup value is in cell E1, which is something you can change according to your needs.
Use an array formula:
I found this formula in the web a few years ago, cant remember where, but credit to them.
=VLOOKUP(CONCATENATE(D2,"a"), CHOOSE({1,2},A$1:A$10 & B$1:B$10, C$1:C$10 ),2,0)
For this example I used column D on the same sheet for the reference ID and column E for the result. Amend the references as required.
Due to this being an array formula, every time the formula is entered you will need to select the formula bar and hold CTRL and Shift and press enter on the keyboard.

Increment count in column based on value in column

I've 2 columns A and B. A contains names and B contains the count of those names till that record as shown below.
-----------------------------------
| A | B |
-----------------------------------
1 | Fruits | 1 |
2 | Flowers | 1 |
3 | Fruits | 2 |
So, want to have a formula for this. Expecting an array formula. Even if an array formula is not possible, a general formula
Attached a spreadsheet so that it can be explained better.
https://docs.google.com/spreadsheets/d/1wlWqdFwgv90s50iP-bXXBHciyualohj610qFiSatcmQ/edit#gid=1997586177
You do not need an array formula, and I would avoid them when possible. You can accomplish your task with
=COUNTIF(A$1:A1,A1)
Where A1 if the first value in the column of values you want to count. The $ allows you to anchor the top of your COUNTIF range while leaving the bottom dynamic.
In a google spreadsheet you may want to try:
=ArrayFormula(iferror(SORT(ROW(A1:A),SORT(ROW(A1:A),A1:A,1),1)-MATCH(A1:A,SORT(A1:A),0)-ROW()+2))
Example sheet

Google spreadsheet relative row numbering + skip empty cell

Using Google spreadsheet, I need a column to show relative row numbering, so that:
Spreadsheet rows can be moved around, and numbering stays relative (meaning that if I move row number 12 between rows 4 and 5, this row becomes number 5, previous 5 becomes 6, etc.)
Using a condition based upon a cell value in a given row, the row numbering cell may be empty (or not); if empty, that row number is being skipped, and numbering takes back up in the next row where the condition is unmatched.
Here is an example:
| Row nbr | B col. | [Explanation] |
|---------|:-------:|-------------------------------------|
| R01 | Value 1 | |
| R02 | Value 1 | |
| R03 | Value 2 | |
| | Value 3 | Col. B value = 3 => Col. A is empty |
| R04 | Value 2 | Numbering takes up |
| R05 | Value 1 | |
| | Value 3 | Col. B value = 3 => Col. A is empty |
| R06 | Value 2 | Numbering takes up |
| ETC. | | |
Here, the condition (to skip numbering) would be "IF corresponding B cell = Value 3" (then skip numbering)
Right now, I'm using a formula that matches requirement #1 above:
=ROW(INDIRECT("A"&ROW()&":A"))-9
(The trailing "-9" is just an offset so numbering can start at 01 from row 10).
So basically, I need to adapt (or change) this code so that besides relative numbering, for row N, if corresponding B column cell value = XYZ, then A column cell is empty (vs. numbered): that row is being skipped, and numbering takes back up from N on the next row where the B cell value ≠ XYZ.
Here's a Google spreadsheet example.
Many TIA's.
I strongly recommend not to use ROW() with explicitly specified offset in formula because should you delete/add rows above your table, your will have to adjust formulas in all cells. Here's my solution (column A:A is row numbers, B:B - values, start adding formula in cell A10):
=IF($B10="Value 3","",ROWS($B$10:$B10)-COUNTIF($B$10:$B10,"Value 3"))
Or if you insist on relative rows (change 10 to your offset from top):
=IF(INDIRECT("B"&ROW())="Value 3","",ROWS(INDIRECT("B"&10&":B"&ROW()))-COUNTIF(INDIRECT("B"&10&":B"&ROW()),"Value 3"))

Incrementing each row in excel that contains a number

I was sent an excel document in the following format:
A | B |
1 | abc |
| def |
2 | abc |
| def |
| ghi |
3 | abc |
| def |
So basically I have the first column which contains ordered numbers every couple of rows. I want to insert a row e.g. between 2 and 3, so that the new row will be numbered 3, and the rows below it are updated accordingly i.e. 3 becomes 4, 4 becomes 5 and so on.
I don't really use excel, but I am curious if there is there an easy way of doing this?
In A1, enter the following formula:
=IF(MOD(ROW(A1),2)=1,(ROW(A1)+1)/2,"")
And copy that formula down to the bottom of the range. Each time you insert a new row, you will need to manually copy the formula to the inserted row's first cell.
Is there a pattern in the b column, to distinguish if you need to jump to the next number?
if so use:
in cel A2 and further:
=IF(B2 = "abc",A1+1,A1)
With conditional formating, hide the repeating numbers: =A2=A1

Resources