How to use count if to get the sum - excel

=countif(E2:E21*E23:E37*I2:I20*I22:I37,VLOOKUP(C3, C2:C21*C23:C37*K2:K20*K22:K37,1,0))
I am trying to use the formula above to do the following: I need to calculate the sum of all non empty cells in the login columns on all the ranges in the sheet that have station type ARSAW. I know all of them are empty right now but I'm speaking of when they are not empty.

Related

To return the last value in a row for Date and Person to Action (VBA)

I wish to construct 2 current status columns so as find the last values in each row in Excel:
one for the last Date and the other for the last person who needs to act.
Please see the attached jpg To return the last values in a row for Date and Person to Act
I have tried to use the excel functions, namely, INDEX or LOOKUP but to no avail because of the 3 Remarks columns within the table.
I would appreciate it if you could advise me how to craft a VBA code to the above query.
From LC TAN 2020-02-13
You're on the right track.
you can use LOOKUP to return the last element in an array
BUT you have to ensure your array only has the elements that you want to consider
There is a variation of the INDEX function where you can enter an array for the column (or row) argument and return selected items. You enter the array, or arra constant, in a format like:
N(IF(1,*array or arrayConstant*))
So, a formula that would work for your requirements would be:
L6: =LOOKUP(2,1/LEN(INDEX($B6:$J6,N(IF(1,{2,5,8})))),INDEX($B6:$J6,N(IF(1,{2,5,8}))))
and fill down.
You can use MAX for the date to find the latest date in that row.
You can then use IFERROR and VLOOKUP to find the action with that date. i.e. lookup the date that MAX has returned in the first set of columns, and if that returns an error, look in the second. If the second returns an error, look in the third.
As per your sheet, the formula for L6 would be =MAX(B5:I5)
The formula for M6 would be =IFERROR(VLOOKUP(L5,B5:C5,2,FALSE),IFERROR(VLOOKUP(L5,E5:F5,2,FALSE),VLOOKUP(L5,H5:I5,2,FALSE)))
You can then drag the cells down to populate the date and action for every row. You could achieve the same with VBA if you wanted to, but I would have thought that this is the easiest way to get the the desired result.

Is there a general way to process only visible cells in excel?

I am wondering, if there is a general way to express, that only visible rows of a formula should be taken into account.
If I have for example a formula sumif($E5:$E100; "ABC"; $F5:F100) it would be very helpful, if there would be a way to express, that the given ranges should only take visible cells into account. I could imagine that a kind of prefix can be specified to a range construct like % or that like. For example the formula then would look like sumif(%$E5:%$E100; "ABC"; %F5:%F100) to make clear, that in the given ranges only visible rows should be taken into account.
Same would then for example be for sum(%A1:%A100) which would mean, that in the range between A1 and A100 only visible cells should be taken to sum up the cells.
The point is, that this construct could be taken inside any kind of formula, no matter what it is.
Thanks in advance
Georg
Generically to sum sumrange based on a match in criteriarange.....but only for visible rows you can use this formula: =SUMPRODUCT((criteriarange=criteria)+0,SUBTOTAL(109,OFFSET(sumrange,ROW(sumrange)-MIN(ROW(sumrange)),0,1,1))) The first part (criteriarange=criteria)+0 just checks the criteria for each row and returns 1 for a match or 0 OFFSET returns an "array of ranges" with each range in this case being a single cell from the sum range. SUBTOTAL can process that and with the sum function (109) gives the "sum" (i.e. the value) of each cell, only when visible. – SUMPRODUCT then multiplies the two ranges and sums the result, effectively giving you the sum of visible rows where the criteria matches
Try This
=SUMPRODUCT(($E$5:$E$100="ABC")+0,SUBTOTAL(109,OFFSET($F$5:$F$100,ROW($F$5:$F$100)-MIN(ROW($F$5:$F$100)),0,1,1)))

Match two columns in two excel files and return value [duplicate]

I am trying to create a simple VLOOKUP function for my spreadsheet using the below:
In the first sheet
=VLOOKUP("Salary",'December 2015_natwest_download'!$D$4:$E$43,1,FALSE)
This is the sheet i am trying to reference:
The sheet I am trying reference:
Value Category
======= ==========
£530.00 Charlotte Owing
-£53.00 Gym
-£16.47 Water
-£67.00 Phone
-£11.01 Presents
-£14.40 Eating out
-£100.00 Food
-£65.00 Other
But when I put the VLOOKUP code into my excel, it returns NA. Can anyone see what is causing the error?
The VLOOKUP function is designed to lookup a value on the far left of a block of data and return a corresponding value from a column to the right.
If you need to lookup a value and return a value from a corresponding column to the left of the lookup column, you need to use an INDEX/MATCH function pair.
If you are returning numbers based on a condition (either in that column or another column) either the SUMIF or
SUMIFS function will do. Individual entries can be easily collected but if there is more than a single match to your condition, you will receive a sum total of the matching numbers.
        
The formulas in E4:F4 are,
=INDEX('December 2015_natwest_download'!A:A, MATCH(D4, 'December 2015_natwest_download'!B:B, 0))
=SUMIFS('December 2015_natwest_download'!A:A,'December 2015_natwest_download'!B:B, D4)
Note that the SUMIFS in F5 is returning two Gym entries.

Trying to specify multiple wildcards in a countifs function for Excel

I am working on a data sheet that has almost 300,000 rows by about 40 columns.
I have a countifs function to count the number of rows that have an entry ranging from "A1" through "A5" for each letter A-G in a particular column.
I have broken out analysis on separate sheets to pull data for each row for each separate letter A-G using countifs(range,"other data","F?") (I know its simplified).
I need to create a new sheet that excludes any row with an A value in it.
I tried countifs(range,"other data", range,{"B?","C?","D?","E?","F?","G?"}) and it only returns the count for the outside values (B and G), how do I get Excel to count all of those other values as well? I would like to keep this format because to create the sheets for B-G, I just used the find and replace to replace "A?" with "B?" and so on for the other sheets.
I would like to just replace "B?" with whatever works to count the number of rows that have B-G in that particular column.
You countifs formula, with an array constant for criteria, returns an array of values. But what you want is the SUM of that array. So:
sum(countifs(range,"other data", range,{"B?","C?","D?","E?","F?","G?"}))
Without the sum function, you will only see the value of the first element of that array.
I have a feeling this is the wrong answer, but I'll say it anyway. Why can't you use
=COUNTIFS(Range,"<>A?")
Or are there other possible values that you want to exclude?
In which case you should be able to use this for A
=COUNTIFS(Range,">=B1",Range,"<=G5")
and for B1-B5
=COUNTIFS(Range,">=A1",Range,"<=A5")+COUNTIFS(Range,">=C1",Range,"<=G5")
which can be modified for C, D, E and F
and this for G
=COUNTIFS(Range,">=G1",Range,"<=G5")

EXCEL Formulas Sum Everything above specific row

I want to SUM everything above a cell that contains the word "SUMTOTAL". So if I have 50 columns I want it to go to first row that has the text "SUMTOTAL" in it and then Sum everything aboce that word. Is it possible?
Use a MATCH formula to find the row and minus one from it then use an INDIRECT formula to put together a string of the address then plop it into a sum formula like this:
=SUM(INDIRECT("A1:A" & MATCH("SUMTOTAL",B:B,0)-1))
Assumption:
SUMTOTAL is in column B somewhere
The numbers you want to sum are in column A
Your data starts at row 1.
You are summing ONE column. To expand simply change "A1:A" to "A1:X" if you wanted to sum columns A to X
I assume that all your data is located in A1:N20, and SUMTOTAL appears somewhere inside this area (you can easily change the desired data location). The following formula does the summation of all numbers directly above SUMTOTAL, i.e., in the same column.
=SUM(OFFSET($A$1,0,SUMPRODUCT(COLUMN($A$1:$N$20)*($A$1:$N$20="SUMTOTAL"))-1,SUMPRODUCT(ROW($A$1:$N$20)*($A$1:$N$20="SUMTOTAL"))-1))
If you want to sum all numbers above SUMTOTAL, no matter if in the same column or not, use
=SUM(OFFSET($A$1,0,0,SUMPRODUCT(ROW($A$1:$N$20)*($A$1:$N$20="SUMTOTAL"))-1,COLUMNS($A$1:$N$20)))
=SUM(INDIRECT(ADDRESS(1,COLUMN())&":"&ADDRESS(ROW()-1,COLUMN())))

Resources