How to express absolute cell references in Excel R1C1-style formulas? - excel-formula

I want to use a fixed start cell in a range for a SUM function.
I'm working with XSLT 1.0 where I create this:
<Cell ss:StyleID="s76" ss:Formula="=SUM(K6:R[-1]C)">
<Data ss:Type="Number"/>
</Cell>
But the the formula appears in Excel as =SUM('K6':K19), and an error message pops up "The formula contains unrecognized text".
I have tried this:
=SUM(R[-14]C:R[-1]C)
but this is not a good option, because the range can be change.

If the formulas are in Column K, and you want to refer to "K6", then that would be R6C ("row 6, same column") in the R1C1 reference style.
So for a range, this:
=SUM(R6C:R[-1]C)
would mean "row 6, same column -to- previous row, same column".

Related

Excel - Identify if Worksheet exists between two worksheets?

I have 5 worksheets: (1) Summary (2) 2020 (3) 2019 (4) 2018 (5) 2017
In my "Summary" worksheet, I have Column A with cells each containing the name of each worksheet (A1: 2020, A2: 2019, A3: 2018, A4: 2017) and Column B with the number "1" in each corresponding row.
Let's say I delete the "2019" worksheet so that it is no longer between worksheets "2020" and "2017" - is there any formula that I could use to flag that in row 2? Perhaps through some sort of "if(..,1,0)" formula for Column B? I do not want to use VBA.
There are various error-checking functions available in Excel, and most of them would be appropriate for your situation. The simplest would be to use IFERROR and just refer to a cell on one of the sheets, like this:
=IFERROR('2020'!A1,"Missing")
If the formula receives an error value because it can't find the cell, it will display the text "Missing"; otherwise, it will show the value of the cell.
The disadvantage of doing it this way, hard-coding the sheet name into the function, is that if the sheet is deleted the sheet name will be replaced in the formula with #Ref!, so even if the sheet is restored the formula will need to be changed.
We can enhance the functionality by using an INDIRECT along with the IFERROR. This will take a text string and turn it into a cell reference. So assuming we have worksheet names in column A, we could do this:
=IFERROR(Indirect(A1 & "!A1"),"Missing")
The INDIRECT function takes the value in A1 and combines it with the text string, and reads the whole thing as a cell reference. This has the same result, but is more robust since deleting the sheet and then replacing it will clear the error.
For a slightly more elaborate result, we could next IF and ISERROR instead of using IFERROR. It gives us more control over the result.
=IF(ISERROR(INDIRECT(A1 & "!A1")),"Missing","Found")
ISERROR returns TRUE if the first argument throws an error, an FALSE if it does not. This will return "Found" if the sheet is present, or "Missing" if it isn't.

Excel - get range of data between two rows

I have data in following pattern:
I want a formula to get the data between Content Start and Content End. The amount of content between the start and end is not just limited to 4 and can change.
You don't say what you want to do with this result.
I am assuming you can code the column in which your data is located.
The formula below will return those values as an array. e.g. with your data, the formula will return {1;2;3;4}
The values could be numeric or text.
How you want to handle those values is up to you.
=INDEX($A:$A,N(IF(1,ROW(INDEX($A:$A,MATCH("Content Start",$A:$A,0)+1,1):INDEX($A:$A,MATCH("Content End",$A:$A,0)-1,1)))))
EDIT: Here is an example of using that information to create a sparkline. In this example, the formula above has been wrapped in TRANSPOSE and entered as an array formula in C1:I1. The Sparkline has been entered in B1. As with most charts, Excel is ignoring the #N/A errors.
And here is an example where the sparkline is in A1 and the transposed array is somewhere else, not in view, on the worksheet:
With Worksheets("Your Sheet").Range("A:A")
Set c = .Find("Content Start", LookIn:=xlValues)
Set d = .Find("Content End", LookIn:=xlValues)
ActiveSheet.Range(Cells(c.Row + 1, c.Column), Cells(d.Row - 1, c.Column)).Select
End With
Probably multiple ways doing this, but if you prefer to do it without VBA you could use:
Formula used in B1 (allthough a bit lengthy):
{=INDEX($A$1:$A$10,SMALL((ROW($A$1:$A$10)>MATCH("Content Start",$A$1:$A$10,0))*(ROW($A$1:$A$10)<MATCH("Content End",$A$1:$A$10,0))*ROW($A$1:$A$10),SUM((ROW($A$1:$A$10)>MATCH("Content Start",$A$1:$A$10,0))*(ROW($A$1:$A$10)<MATCH("Content End",$A$1:$A$10,0)))+ROW(A3)))}
Notice it's an array formula entered through CtrlShiftEnter
Drag down....

Three Dimension Vlookup

I have a master table with the following structure in excel :
How can I convert it as shown in the second picture by using the vlookup function? (function in yellow cells).
Three keys involved now: Daytime, User and Data Type (ADP_ERQ, ADP_SO)
Note: Column headers (Daytime, User, ADP_ERQ, ADP_SO) in the second picture are fixed.
Try this in C17 then fill right and down.
=INDEX($A$3:$Z$12, MATCH($A17, $A$3:$A$12, 0), AGGREGATE(15, 7, (COLUMN(1:1)+MATCH($B17, $1:$1, 0)-2)/($2:$2=C$16), 1))
For cell C17: IF(B17="USER_A",VLookup(A17,A3:C12,2,0),VLookup(A17,A3:E12,4,0))
For cell D17: IF(B17="USER_A",VLookup(A17,A3:C12,3,0),VLookup(A17,A3:E12,5,0))
In this formula replace A3:C12 and A3:E12 with your appropriate table range, then drag these down.

Excel: Use Cell Range which is saved in a cell for completing a formula in another cell

In the above Table i would like to use the range defined in V2 for the formula defined in E2. It should replace the green underlined part of the formula. As you can see there is already the right range in there but it is for flexibility reasons if the range changes so i don't have to change all the formulas which are in E2,F2,G2,... and so on.
The Formula:
=VLOOKUP("contract index",INDIRECT("'PURCHASING'!"&V2),2,FALSE)
Try,
=vlookup("contract index", indirect("'purchasing'!" & v2), 2, false)

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:

Resources