Using IsNumeric Function in a Formula - excel

I was wondering if anyone had any suggestions for what I'm doing wrong, or if it's even possible.
I am working with 3 columns:
Column X = # of Services, Column Y = # of Bills, and Column Z which is a calculation of X divided by Y.
Sometimes, there is a text entry in Column X - when that happens, I want Column Z to simply reflect what Column Y contains.
Here is the code I've written... I've tried (seemingly) all possible combinations of quotation marks and parentheses, to no avail.
ActiveCell.FormulaR1C1 = _
"=IF(IsNumeric(RC[-2]),=RC[-2]/RC[-1],=RC[-1])"
Thank you!

Your formula is wrong, use this:
ActiveCell.FormulaR1C1 = "=IF(IsNumber(RC[-2]),RC[-2]*RC[-1],RC[-1])"
Note that IsNumeric is a VBA function and its equivalent in Excel functions is IsNumber. Sometimes functions have different names for Excel and VBA, this is one of the cases.

Related

COUNTIF(S) in two column and get the unique count

Is there any formula that can count in two columns and only return the unique count.
I have a table where two columns could have an "X", I want to count the "or" of this "X".
Meaning if it's in one or the other or both column(s) then count that, else don't.
Example:
A B C
foo X
bar X
Doo X X
Boo
The expected result is 3 (foo, bar, Doo).
I can't do a =COUNTIF(B:B, "X") + COUNTIF(C:C, "X") since that will give me 4.
=COUNTIF(B:C , "X") returns 4.
SUMPRODUCT((B:B="X")*(C:C="X")*1) = 1, SUMPRODUCT((B:C="X")*1) = 4
Is there any formula that could count this case?
Sadly I don't have Office 365 at work
If one has Excel O365, you could try:
=COUNTA(UNIQUE(FILTER(A:A,(B:B="X")+(C:C="X"))))
If you have an older version of Excel, maybe try:
=SUM(--(FREQUENCY(IF((B1:B4="X")+(C1:C4="X")>0,MATCH(A1:A4,A1:A4,0)),ROW(A1:A4))>0))
Not, this last formula is an CSE-entered formula in Excel prior to O365. Also, if your data starts at a different row you'd need to adjust the formula accordingly. See this link that will explain how.
If you just want to count the rows that contain at least one "X", try:
=SUMPRODUCT(--(B:B&C:C={"X";"XX"}))
This would simply concatenate columns B&C and then check if the resulting value is either "X" or "XX". Depending if you do not even have headers it can be even simpler:
=SUMPRODUCT(--(B:B&C:C<>""))
If you want te minus the header: =SUMPRODUCT(--(B:B&C:C<>""))-1
Use concat formula in column D such that D1=CONCAT(A1,B1) , D2=CONCAT(A2,B2) and so on.
D1=CONCAT(A1,B1)
Then use counta function on column D to count all cells that are not blank, simple as that , i hope.
=COUNTA(D:D)
Does that help you ?
OR Alternatively Try,
= COUNTIFS(B:B, "X",C:C, "") + COUNTIFS(B:B, "",C:C, "X") + COUNTIFS(B:B, "X",C:C, "X")
If you have Excel365 then can use FILTER() function with COUNTA().
=COUNTA(FILTER(A1:A4,(B1:B4="x")+(C1:C4="x")))
See if below implementation of SUMPRODUCT is useful for you.
=SUMPRODUCT(--ISNUMBER(SEARCH("X",B2:B5&C2:C5,1)))
Or it needs to be tight and avoid issues like wild card matches etc. then you can also try:
=SUMPRODUCT(--(((B2:B5="X")+(C2:C5="X"))>0))

excel function to vba code (exclusive quartile & if function)

I am trying to get this piece of excel function into vba code (mainly because there is no such thing as "application.worksheetfunction.if" - would be great if i can get some help here!
=quartile.exc(if((F:F=F2)*(Y:Y=1),I:I),1)
basically, i wanted to find the 25th percentile of all data in column I if two criteria are met: 1) if value of column F is the same, 2) if column Y value = 1. Otherwise return to blank.
Thank you very much!
If that formula gets you the answer you want, then you could simply use:
Activesheet.Evaluate("=QUARTILE.EXC(IF((F:F=F2)*(Y:Y=1),I:I),1)")

How to use multiple columns for texts in Excel

I have multiple columns as follows
A B C D Outcome
Y Y
N N
N N
Y Y
My outcome is in the column E. If the cell is filled, I want to see it in the outcome column. If not I want to see a blank cell. I tried my best, but I could do it. Is there a simple function to do it. Thanks for your help.
There are a number of ways to accomplish this. One would be:
// Copy this down
In Cell E2: =IF(COUNTA(A2:D2)=0,"",CONCATENATE(A2,B2,C2,D2))
Try :
=A2&B2&C2&D2

Triple (nested) if-formula Excel 2010

Trying to work out how to set up this nested if-formula.
I've got 3 different dates, and i want the formula to pick date x first, when this is empty, get y, and if that turns up empty, get date z.
I've tried it with =IF(z2="";aa2;z2;IF(aa2="";v2;aa2)) and this gives me the error that i'm adding to much arguments.
Date x = cell Z2
Date y = cell AA2
Date Z = Cell V2
The reason I'm asking this question is because i keep having a hard time with these types of formula and hoping to find someone who could explain what I'm doing wrong, or that my approach is wrong.
Either use
=IF(Z2="";IF(AA2="";V2;AA2);Z2)
or
=IF(Z2<>"";Z2;IF(AA2<>"";AA2;V2))
Let me know if anything is not clear.

excel Formula to sum values in a column based on another value(txt) in any column

I'm trying to write an If or SumIf to calculate(sum) totals for x , y and z individually.
I could use a simple sum formula but these are thousands of columns and x and y and z are populated randomly. I tried using a range by sorting colA but its a temporary solution and not what I am looking for.
I need something like:
If COL A has 'X' then add values corresponding to X in COL B
example:
COLA COLB ....... colx
x 1
x 2
x 1
y 3
x 3
z 3
x 4
I tried looking up other answers for similar questions but could not find the right one that works for me.
If you want to sum multiple columns based on a value in a single column you could use SUMPRODUCT like this
=SUMPRODUCT((A2:A100="x")*B2:X100)
There can't be text in the sum range, B2:X100, otherwise you get an error - if you want to allow text in that range use this version:
=SUMPRODUCT((A2:A100="x")*ISNUMBER(B2:X100),B2:X100)
Maybe (difficult to tell from the question):
=sumif(A:A,"=x",B:B)
Another answer could be that you create a pivot table of the database. Insert>Pivot Table>Select your table range. Then from there, you would put the column heading you wanted sorted into the row criteria, and then sum the x1's and y'1s.
I am assuming you want to obtain subtotals for each column and each letter, as in the figure below.
If so, enter in B12 the formula
=SUMPRODUCT(($A$2:$A$8=$A12)*(B$2:B$8))
Copy and paste into B12:C14. It is easy to adapt to slightly different arrangements.
I apologize if my question was vague. This is my first time working with if and sumif formulas in Excel.
This is what I was looking for: =sumif(A:A,"=x",B:B).
Thank you Pnuts.

Resources