Excel nested conditional formatting with indirect references - excel

I am working on a MS Excel 2010 spreadsheet where the users want to have some combined conditional formatting.
Individually the functions I want to apply are working correctly, i.e this condition formula works:
= INDIRECT( ADDRESS( IF( ISEVEN( ROW() ), ROW() - 1, ROW() ), 22) ) = "6 Monthly"
As does this:
= OR( COLUMN() = 25, COLUMN() = 28)
But combining the formulae fails to apply any format. No error is returned, but the highlighted area is unaffected on applying the condition:
AND( INDIRECT(ADDRESS(IF(ISEVEN(ROW()), ROW() - 1, ROW()), 22)) = "3 Monthly", OR( COLUMN() = 25, COLUMN() = 28) )
If I want the cells where both conditions are met to be highlighted, what should I enter as the formula?

This works for me:
=(INDIRECT(ADDRESS(IF(ISEVEN(ROW()),ROW()-1,ROW()),22))="3 Monthly")*(OR(COLUMN()=25, COLUMN()=28))

Your conditional formatting formulas seem overly complex to me
Select Y11:Y48 and then hold down CTRL key and also select AB11:AB48 and apply the conditional formatting formula
=$V11="3 Monthly"
Format as required
That will highlight the column Y and AB cells in every row where col V = "3 Monthly" - isn't that the requirement?

Use IF:
=IF(INDIRECT(ADDRESS(IF(ISEVEN(ROW()),ROW()-1, ROW()),22))="3 Monthly",OR(COLUMN()=25,COLUMN()=28),0)
Hope this helps.

Related

Excel TEXTJOIN Multiple Categories Formula

I am looking for an Excel 365 formula to join data together in a single cell by a category and the data to be further broken out buy a subcategory on separate lines within the category cell. Please see my example data and results. I would be grateful for any help with formula ideas.
example data
results
I attempted to use TEXTJOIN and UNIQUE functions, but was not sure how to embed the multiple categories TEXTJOIN within a formula.
You could try something along the lines :
• Formula used in cell F18
=LET(x,FILTER($B$2:$C$16,$A$2:$A$16=E18),
y,DROP(x,,-1),z,DROP(x,,1),u,UNIQUE(y),
TEXTJOIN(CHAR(10),,MAP(u,LAMBDA(m,m&" - "&ARRAYTOTEXT(FILTER(z,m=y))))))
Or, you could spill the formula for the whole range
• Formula used in cell F18
=DROP(REDUCE(0, E18:E20, LAMBDA(a,b, VSTACK(a,
LET(f, FILTER($B$2:$C$16, $A$2:$A$16 = b),
y, DROP(f, , -1), z, DROP(f, , 1), u, UNIQUE(y),
TEXTJOIN(CHAR(10), , MAP(u, LAMBDA(m, m & " - " & ARRAYTOTEXT(FILTER(z, m = y))))))))), 1)
Note: Select the formulated range and wrap the cells, by hitting ALT+H+W.
Relatively alike to the other answer:
Formula in A18:
=REDUCE({"Category","Results"},UNIQUE(A2:A16),LAMBDA(a,b,VSTACK(a,HSTACK(b,TEXTJOIN(CHAR(10),,MAP(UNIQUE(FILTER(B2:B16,A2:A16=b)),LAMBDA(x,x&" - "&TEXTJOIN(",",,FILTER(C2:C16,(A2:A16=b)*(B2:B16=x))))))))))

IF Statement on Excel/Google Sheets

I'm trying to find a formula in which K4 returns completely blank when J4 is empty. As you can see in the image, it's returning £0.00, but I need it to be blank?
this is how you do it in Google Sheets:
=IF(LEN(J4), IF(J4="Won", H4*I4, 0)+IF(J4="Lost", 0, 0), )
and whole your formula can be shortened to:
=IF(LEN(J4), IF(J4="Won", H4*I4, 0), )
If you want to return a true blank, just skip the return argument
For instance
IF(J4 = " ",)
If this does not work due to formatting disagreements with the above equation, you can return a blank with the below as well
IF(J4 = " ", IFERROR(0/0))
I might be wrong, but I don't think you can enter a formula and get a completely blank return value.
The next best thing you can do is return a zero-length string "" -- which isn't the same as a blank cell but might work for you nonetheless.
Maybe you can nest your formula in =IF(ISBLANK(K4),"",<put the rest of your formula here>).

Nested conditional formatting for self referencing cells

I am formatting an excel sheet and want to apply a conditional format to a range of cells for when the particular cell matches the one either above or below it, AND when the corresponding cell in the adjacent column matches the cell either above or below it.
an example of the information in the columns:
Name Ref ID
PER 002-003
PPJ 021-006
PPJ 021-006
PPJ 021-006
RAD 005-013
REI 006-009
RIT 005-085
STJ 002-003
STJ 002-003
TEL 002-013
TEL 007-014
So in this section of the sheet PPJ & STJ should Highlight/fill but TEL should not since while the name matches the REF ID doesn't.
I have tried:
=AND(
OR(
INDIRECT(ADDRESS(ROW(), COLUMN())) = INDIRECT(ADDRESS(ROW(), COLUMN(),-1,0)),
INDIRECT(ADDRESS(ROW(), COLUMN())) = INDIRECT(ADDRESS(ROW(), COLUMN(),+1,0))
),
OR(
INDIRECT(ADDRESS(ROW(), COLUMN(),0,+1)) = INDIRECT(ADDRESS(ROW(), COLUMN(),-1,+1)),
INDIRECT(ADDRESS(ROW(), COLUMN(),0,+1)) = INDIRECT(ADDRESS(ROW(), COLUMN(),+1,+1))
)
)
but get no response from the cells regarding the formatting changes. I have tried substituting offset for the second OR statement referring to the adjacent column but get an error about too many arguments.
Am I taking an incorrect approach to this or am I missing a step?
You shouldn't need that level of complexity. For conditional formatting you can just apply the formula that applies to the top left cell of the range, so if your data is in D3:E14 for example then you only need to use the formula that applies to D3.....so follow these steps
Select the range to format (D3:E14 in my example)
Apply conditional formatting with the formula that applies to the top left cell of the range, i.e. for your problem
=AND(OR($D3=$D2,$D3=$D4),OR($E3=$E2,$E3=$E4))
Choose required format > OK > all done
Excel will implicitly adjust the conditional formatting formula for the whole "applies to" range as if you were dragging that formula on the worksheet, so it will work as required for the whole range
Given your sample data above here's the screenshot of that CF formula applied to your data:

Group on excel rows to a single cell by column id

I have a question regarding excel.
I have two columns, column A has a number and B has country codes. I'm looking for a way to automatically go through 100's thousands of rows to group them so they look like the following...
Is this doable? I'm at a complete loss :(
THE END RESULT
6512 AG,AI,AW,BB,BL,BM,
6513 BQ,BS,BZ,CA,CR
STARTING POINT - column A & B
6512 AG
6512 AI
6512 AW
6512 BB
6512 BL
6512 BM
6513 BQ
6513 BS
6513 BZ
6513 CA
6513 CR
These solutions use a working column named Concatenated Results.
Assuming your data has a header (adjust formulas as required) and is located at B6:C34 (change as required) as in fig below.
Data sorted by ID:
Concatenated Results: Enter this formula in D7.
= CONCATENATE( C7, IF( EXACT( B7, B8 ), "," & D8, "" ) )
ID.Unique: Enter this Array Formula in E7 (FormulaArrays are entered pressing CTRL+SHIFT+ENTER simultaneously, you shall see { and } around the formula if entered correctly)
=IFERROR( INDEX( $B$7:$B$34,
MATCH( 0, COUNTIF( $E6:$E$6, $B$7:$B$34 ), 0 ) * 1 ), "" )
Countries: Enter this formula in F7
=IFERROR(VLOOKUP(E7,$B$6:$J$34,3,0),"")
Copy range D7:F7 till last row of data (i.e. row 34).
Data not sorted: If the data is not sorted enter this formula for the Concatenated Results in D7. All other formulas remain unchanged.
=CONCATENATE( C7,
IF( ISERROR( MATCH( B7, B8:B$35, 0 ) ), "",
"," & VLOOKUP( B7, B8:D$35, 3, 0 ) ) )
Suggest to read the following pages to gain a deeper understanding of the resources used:
Excel functions (alphabetical), Create an array formula, Guidelines and examples of array formulas
Try this out and let me know in case of any queries or if you require detailed explanation.
Step1: Filter the data by column A.
Step2: Make a new column C where use this formula IF(A2=A1,CONCATENATE(B2,",",C1),B2) .
Step3: Make a new column D where use this formula IF(A2=A3," ","REQUIRED_ANS") .
Step4: Filter on column D using ALT + D + F + F and you get you desired output.
My Output:
This is a VBA solution
Assuming your data, excluding header, is located at B7:C34 (change as required).
ID.Unique: Enter this Array Formula in E7 (FormulaArrays are entered pressing CTRL+SHIFT+ENTER simultaneously, you shall see { and } around the formula if entered correctly)
=IFERROR( INDEX( $B$7:$B$34,
MATCH( 0, COUNTIF( $E6:$E$6, $B$7:$B$34 ), 0 ) * 1 ), "" )
Countries: Enter this User Defined Function (UDF) in F7
=Match_Concatenated(E7,$B$7:$C$34)
Copy this UDF code in a VBA Module
Option Explicit
Public Function Match_Concatenated(vValue As Variant, rTrg As Range) As String
Dim sOutput As String
Dim vTrg As Variant, vItm As Variant, lRow As Long
vTrg = rTrg.Value2
For lRow = 1 To UBound(vTrg)
vItm = WorksheetFunction.Index(vTrg, lRow, 0)
If vItm(1) = vValue Then sOutput = sOutput & Chr(44) & vItm(2)
Next
sOutput = Replace(sOutput, Chr(44), vbNullString, 1, 1)
Match_Concatenated = sOutput
End Function
Suggest to read the following pages to gain a deeper understanding of the resources used:
Excel functions (alphabetical),
Create an array formula,
Guidelines and examples of array formulas,
Option Explicit Statement,
Range.Value2 Property (Excel), For...Next Statement,
WorksheetFunction Object (Excel), INDEX function,
If...Then...Else Statement, Replace Function

Excel: Custom a conditional format rule: if cells in colums C are not empty, then

I am trying to use a custom conditional format rule: if cells in column C are not empty, then color all other cells of the same line in green.
What should I enter in the cell of the Conditional Format Rule option? (http://hpics.li/9492511)
Should I use something like "not blank"?
Assuming headers are in row 1 and actual data starts in row 2, use this conditional format formula:
=AND($C2<>"",COLUMN(A2)<>3)
Apply it to the range that contains your data, in this example, I applied it to range $A$2:$E$21 and here is an image of what the result would look like:
Conditional formatting only works for the same cell, unfortunately.
You can use VBA to check the cell, and format other ones based on that formatting.
for(i = 0 to NUM_ROWS)
if cells(i,3).value = ""
for(j = 0 to NUM_COLS)
cells(i,j).Interior.Color = RGB(33, 173, 28)
next
end if
next
I haven't tested it, but it should be pretty close.
Actually, it looks like you could do this with conditional formatting.
for your formula you'd want
$C1 = ""
This should work for every value.

Resources