My intention is to use the indirect formula. Here is the code I want to edit:
=COUNTIF('sheetname'!R:R;"x")
This code gives a #ref! error:
=INDIRECT("COUNTIF('"&D85&"'!R:R;"&B98&")")
Cell D85 contains sheetname and B98 contains "x".
My version of Excel needs ; in formulas instead of ,.
Thanks in advance for your expertise and time.
Try this formula:
=COUNTIF(INDIRECT("'"&D85&"'!R:R");B98)
My read on Indirect says that it simply uses the cell reference contained in the cell you specify in the function:
Indirect( cellContainingReference )
In this case, you don't need to specify the second parameter of Indirect.
So, using the assumptions:
sheetName is in cell D85
cellRange is always R:R
criteria for counting is in cell B98 (which does not need Indirect to work)
Your excel uses ';' rather than ','
Your formula for CountIf would be:
=countif(indirect("'"&D85&"'!R:R"); B98)
With some modification it works, I hope this is a good compromise for you. The modified formula is
=COUNTIF(INDIRECT(E1); F1)
and in this case that E1 should contain something like
''sheetname'!R:R
(See the double apostrophes at the beginning.)
F1 should contain the "X" or other value you want to count.
Related
I need to check if numbers are there after underscore symbol and put that numbers count as shown below.
I am very new to excel, please how to write a formula for this.
Thank you so much in advance
Perhaps you can try something like this. Not sure about your Excel Version.
• Formula used in cell B1
=REPLACE(A1,FIND("#",SUBSTITUTE(A1,"_","#",5)),255,
"_\d{"&LEN(-LOOKUP(0,-RIGHT(A1,ROW($ZY$1:INDEX($Z:$Z,LEN(A1))))))&"}")
If you have access to MS365 then you could try as below,
• Formula used in cell C1
=LET(x,TEXTSPLIT(A1,"_"),
c,LEN(TAKE(x,,-1)),
TEXTJOIN("_",,DROP(x,,-1),"\d{"&c&"}"))
I tried made it short in MS365 version
• Formula used in cell D1
=TEXTBEFORE(A1,"_",-1)&"_\d{"&LEN(TAKE(TEXTSPLIT(A1,"_"),,-1))&"}"
With One Spill Array Formula.
• Formula used in cell D1
=MAP(A1:A3,LAMBDA(m,
TEXTBEFORE(m,"_",-1)&"_\d{"&LEN(TAKE(TEXTSPLIT(m,"_"),,-1))&"}"))
I make the assumption that the characters "cm_" are always before the number:
=len(mid(A1,find("cm_",A1,1)+3,30))
The len() counts the number of characters,
mid() gets the numbers occurring after the text defined in find()
Then:
LEFT(A1,FIND("cm_",A1,1)+2)&"\d{"&LEN(MID(A1,FIND("cm_",A1,1)+3,30))&"}"
My output is here in cell D2..
=REPLACE(C2,MATCH(TRUE,ISNUMBER(--MID(C2,SEQUENCE(LEN(C2)),1)),0),LEN(C2),"\d{"&SUMPRODUCT((ISNUMBER(--MID(C2,SEQUENCE(LEN(C2)),1))*1))&"}")
if your excel doesn't support for Sequence function then you can use ROW(INDIRECT("1:"&LEN(C2)) instead..
I have a pile of data on Sheet1
I have a SUMIFS formula on Sheet2
The columns I am summing are named NETPERD1, NETPERD2, NETPERD3.....NETPERD12
I want to write the SUMIFS so that I can easily change which column I am summing.
On Sheet2, in cell $C$4, I will enter NETPERD1 or NETPERD2 etc. and I want my SUMIF to determine which column it should sum.
I think I should be able to do this with IndexMatch but I can't get it to work.
Here is my SUMIFS that works.
I want to replace NETPERD1 with $C$4
=SUMIFS(Sheet1!NETPERD1,Sheet1!ACCTGRPCOD,Perplas!$A15,Sheet1!AUDTORG,Perplas!C$1,Sheet1!FSCSDSG,Perplas!C$2,Sheet1!FSCSYR,Perplas!C$3)
If your named ranges span the entire column, then for the INDEX/MATCH try:
=SUMIFS(INDEX(Sheet1!$A:$Z,,Match(Perplas!C$4,Sheet1!A$1:Z$1,0)),...
changing the Z to your rightmost column.
Try using the indirect function. You can supply indirect with a character string that Excel then reads as part of a cell/range reference.
Working off the code you shared + the fact that you said that you'll put in the name of the range in cell C4:
=SUMIFS(INDIRECT("Sheet1!"&$C$4),Sheet1!ACCTGRPCOD,Perplas!$A15,Sheet1!AUDTORG,Perplas!C$1,Sheet1!FSCSDSG,Perplas!C$2,Sheet1!FSCSYR,Perplas!C$3)
I think that should work? I'm a little confused about how you're able to reference the row name without a named range, so that might cause a wrinkle in this.
I have several cells that calculate totals from a single cell from multiple worksheets, in this case "Y3" from each of the sheets that are in Week, where n is an integer from 1 through 10:
=SUMPRODUCT(COUNTIF(INDIRECT("'Week"&{1,2,3,4,5,6,7,8,9,10}&"'!Y3"),"W"))
I would like to have a cell in my workbook that contains, A1:
1,2,3,4,5,6,7,9,10
So that way I can update only one cell when I add a worksheet to be counted. I've tried a few things and nothing seems to work.
Your formula : =SUMPRODUCT(COUNTIF(INDIRECT("'Week"&{1,2,3,4,5,6,7,8,9,10}&"'!Y3"),"W"))
This formula only work if you have 10 sheets with named Week1,Week2,Week3….Week10
But if you have less than 10 sheets e.g. Week1,Week2,Week3….Week9, your formula will fail and return "#REF!" error
The formula workaround is wrapping with a IFERROR() and become :
=SUMPRODUCT(IFERROR(COUNTIF(INDIRECT("'Week"&{1,2,3,4,5,6,7,8,9,10}&"'!Y3"),"W"),0))
However, if you wanted the formula acting dynamic and in A1 enter : 1,2,3,4,5,6,7,9,10
But 1,2,3,4,5,6,7,9,10 is a text string, you need converted it to an array. Using FILTERXML() can do the work of which available since Excel 2013
This is an array formula you need to confirm by pressing CTRL+SHIFT+ENTER instead of just ENTER:
=SUM(IFERROR(COUNTIF(INDIRECT("'Week"&FILTERXML("<a><b>"&SUBSTITUTE(A1,",","</b><b>")&"</b></a>","//b")&"'!Y3"),"W"),0))
EDIT 1 :
And,
if you haven't Excel 2013, you could use this longer array (CSE) formula instead
=SUM(IFERROR(COUNTIF(INDIRECT("'Week"&TRIM(MID(SUBSTITUTE(","&A1,",",REPT(" ",99)),ROW(INDIRECT("1:"&LEN(A1)-LEN(SUBSTITUTE(A1,",",))+1))*99,99))&"'!Y3"),"W"),0))
After that,
you can make adjustment to A1 number without changing formula contents
AFAIK you can't do that with a formula if you place the sheet list in a single cell I stand corrected: see bosco_yip's answer! (although you could with a UDF).
But, if you place your sheet list in a column, you can do this (using OFFSET, the list is dynamic, but must be the only data in that column. There are alternatives if that doesn't suit you):
=SUMPRODUCT(COUNTIF(INDIRECT("'Week"&TRANSPOSE(OFFSET(A1,1,0,COUNTA(A:A)-1,1))&"'!Y3"),"W"))
Applying the FILTERXML method, to create a non-array formula
=SUMPRODUCT(COUNTIF(INDIRECT("'Week"&FILTERXML("<a><b>"&SUBSTITUTE(A2,",","</b><b>")&"</b></a>","//b")&"'!Y3"),"W"))
This phrase is embedded in many formulas on my sheet:
OFFSET(Table1[ReportDate],0,$B$1)
It returns a reference to a column in Table1.
To make those many formulas shorter, I'd like to extract this OFFSET formula to a separate cell for the others to refer to.
The OFFSET returns a reference. Putting OFFSET(…) in a cell just returns #VALUE, and so does INDIRECT(OFFSET(…)).
EDIT: The "many formulas" are SUMIFS, and the OFFSET chooses the column to be summed:
=SUMIFS(OFFSET(Table1[ReportDate],0,$B$1),Table1[ColumnB],$H10,Table1[Report Date],"<="&rYesterday)
If I understand you correctly, you want to replace the original OFFSET formula with something simpler to be used in other formulas.
You can do so by giving a name to this OFFSET formula.
In the above mock-up example, I have given a name SUM_Rng for the OFFSET formula and used it in my second formula, which is the same as your original SUMIFS formula.
You can press Ctrl+F3 to bring out the Name Manager in Excel and add or modify names which can represent a reference of a cell or a range either hard-coded or returned by a formula. I noticed that you already used a name rYesterday in your SUMIFS formula so there should be no problem for you to add this formula to the name manager.
Cheers :)
I have need to enter a value that can vary. It is the last row in a column. I add this variable cell to A1. The value is $L$9001
I have the following formula: =VLOOKUP($H4,'week ending 04JUL'!$A$1:$L$9001,3,FALSE)
In A1 I have the value $L$9001. This figure may change hence why I need to add it in and can't use a hardcoded value.
In B1 to test I get the correct output I have: =INDIRECT("A1")
This returns $L$9001 as expected
When I try: =VLOOKUP($H4,'week ending 04JUL'!$A$1:INDIRECT("A1"),3,FALSE)
This returns a #VALUE error.
So I need the value in A1 to replace $L$9001 portion of the formula. Any help is greatly appreciated.
You're almost there, Indirect works slightly different. Try this:
=VLOOKUP($H4,Indirect("'week ending 04JUL'!$A$1:"&A1),3,FALSE)
You put the whole range in the Indirect() field, not just the part you're referring to. Also, note the use of quotes (") starting the Range, wrapping your reference into basically a string that Excel uses.