repeating a formula conditionally in excel 2013? - excel

I am trying to calculate a formula and then dragging it to apply it for the whole column but the problem is that I want to compare first cell of the column A with the first cell of the column B and then second cell of the column A with the second cell of the column B and then compare third cell of the column a with the first cell of the column B... :
A B result
1 1 4 0
2 2 5 0
3 3 0
4 4 0
5 5 1
6 5 1
when i write the pattern like if =IF((A1<Sheet1!B1),0,1) then =IF((A2<Sheet1!B2),0,1) ,=IF((A1<Sheet1!B1),0,1),=IF((A2<Sheet1!B2),0,1)
Four times and then dragging the formula for the column it start comparing it with the correspond one =IF((A5<Sheet1!B5),0,1) How should i change it ?
edit :
in the example I want to compare cell(1,A) with cell(1,B) then cell (2,A) with cell (2,B) and then cell(3,A) with cell(1,B) then cell (4,A) with cell (2,B) and then cell(5,A) with cell(1,B) then cell (6,A) with cell (2,B).[repeating the pattern two times and then start over]

Try this in C1,
=--NOT(A1<OFFSET('Different Sheet'!$B$1, MOD(ROW(1:1)-1, 2), 0))
Fill down as necessary. You only seem to be looking for a 0 or a 1 so I've simplified your IF statement. (Note: maths with MOD adjusted for more universality)
For different multiples you should only have to change the divisor parameter of the MOD function. The ROW function used as ROW(1:1) will return 1, 2, 3, 4, 5, etc as you fill down. MOD returns the remainder of a division operation so MOD(ROW(1:1)-1, 3) filled down will return 0, 1, 2, 0, 1, 2, 0, etc.
If you used the COUNT function on the numbers in 'Different Sheet'!B:B, you should be able to achieve a dynamic divisor.
=--NOT(A1<OFFSET('Different Sheet'!$B$1, MOD(ROW(1:1)-1, COUNT('Different Sheet'!B:B)), 0))

Related

Excel-Is is able to return current result if the condition fails

Below table describes what I expect for.
The "Count Blank" Column is a counter for counting continuous blank cells in order from Column A to Column C. If any of the following cell has value then stop counting and return current value. (plz see row6 and row7)
Basically, I'm looking for a formula which could return the current counter value if the condition fails.
Count Blank
Column A
Column B
Column C
0
1
2
3
1
2
3
2
3
3
1
2
0
1
These two formulas are just for counting the blank cells in the range:
=COUNTIF(B8:D8,"")
=SUM((IF((B8:D8)="",1,0)))
Hoping anyone can help with the continuous problem.
Count Blank
Column A
Column B
Column C
0
1
2
3
1
2
3
2(should be 1)
2
2(should be 0)
1
I found this: https://exceljet.net/formulas/get-first-non-blank-value-in-a-list
You don't really want to count anything, you just need to find the first non blank cell. You can try this formula:
=IFERROR(MATCH(FALSE;ISBLANK(B2:D2);0)-1;COLUMNS(B2:D2))
This is an array formula, so press ctrl+shift+enter when entering it into a cell.
You can use the new (as of 2020) reduce and lambda functions:
=VALUE(REDUCE(0, B1:D1, LAMBDA(prev, curr, IF(ISTEXT(prev), prev, IF(curr = "", prev + 1, TEXT(prev,"0"))))))

looping through columns to adjust formula

i have 3 rows of data and 17 columns, in row 2 depending on a selection (low, med, high, which is cell referenced as say 1, 2, 3) i want to have formula that if low is selected row 2 would equal corresponding column in row 1 and add 1.
effectively some code i was thinking of is:
For i = 2 to 17
Cells(2,i).Formula = "Cells(1,i) + 1"
I need the output to actually be a formula and not a value though

A function or VBA code to determine the last digit in a number

In Excel 2016 I have multiple rows containing numbers no greater than 3 characters listed in column A. I am trying assign a group number based on the right most character in each row that are in column A. Once the number is determined the result is placed in column B of the corresponding row.
Example:
If rightmost character of the number is: a 1 or 6 in cell A1, then in column B1 it's given a 1.
If A1 is a 2 or 7 then B1 is 2.
If A1 is a 3 or 8 then B1 is 3.
If A1 is a 4 or 9 then B1 is 4.
If A1 is a 0 or 5 then B1 is 5.
Any suggestions on how to perform with a function or VBA code are appreciated.
Following your problem statment exactly: in B1 you can enter the formula:
=IF(MOD(MOD(A1,10),5)=0,5,MOD(MOD(A1,10),5))
And copy it down as needed.
The part MOD(A1,10) pulls off the last digit. You seem to want the remainder of this mod 5 -- hence the outer MOD in (MOD(MOD(A1,10),5). But -- if the mod is 0 you want to report it as 5 -- hence the overall IF
However -- an even quicker way is just:
=IF(MOD(A1,5)=0,5,MOD(A1,5))
Since literally pulling off the first digit is superfluous since 5 is a divisor of 10.
Finally, #chrisneilsen gave an elegant formula which is even shorter:
=MOD(A1-1,5)+1
For all remainders other than 0 , the -1 inside the MOD and the +1 outside cancel each other, but for multiples of 5 (remainder 0) the -1 inside the MOD converts the number to one with a remainder of 4, with 4 + 1 = 5 the final answer.

Look up for highest value from another column if values are equal excel

***1 2 3***
a 2 3
b 3 4
c 4 3
d 5 2
so I know to get the highest value I do
=INDEX(column1, MATCH(MAX(column3), column3, 0))
... which would give me 'b'
now I want to get the second highest value based on the column 3 but because there are two cells with 3 (which is the second highest value) I want to use the one that has the lowest value in column 2 based on those two rows. Is this possible?
Use a 'helper' column that adds column C + (column B ÷ 10) and use a modification of your original formula on that column.
        
The standard formula in F5 is,
=INDEX(A$2:A$5, MATCH(AGGREGATE(14, 6, D$2:D$5, ROW(1:1)), D$2:D$5, 0))
Fill down as necessary.

Alternating Columns on a Array Formula in Excel

I have a spreadsheet where data is spread in alternated columns. Columns A, C and E are flags indicating if the adjacent column has a valid data.
It is like this:
A B C D E F
1 1 32 0 67 1 34
The goal is to sum values where its left adjacent is 1. In this example, the sum should be 66, as A and E are both 1 and C is 0.
I can get an array with 1's and 0's indicating if a flag column is set or not:
=MOD(COLUMN(A1:F1),2)*A1:F1
And that gives me
{1, 0, 0, 0, 1, 0}
The thing is that I don't know what I can do from here. If I could slide all the data (by inserting a 0 at the beginning and removing the 0 at the last position), I could SUMPRODUCT it and get the result.
By the way, I can't use macros...
Ideas?
Notice that Formula bellow has two cell ranges one starts at column A the other at B.
=SUMIF(A1:F1,1,B1:G1)
If you are not famliar with SUMIF then what you need to know about this is that first term A1:F1 is where formula checks values for a condition. What condition you might ask values that equal to seconds term in this case =1. Lastly last term has the values that need to be sumed.
Also since you may have issuse of having 1 in an Even column( where you'd expect value not you condition), heve is a formula that makes sure that your 1 & 0 condition is in correct Column:
=SUM(IF((A1:F1=1)*ISODD(COLUMN(A1:F1)),B1:G1,0))
Simple version:
=SUM(A1*B1,C1*D1,E1*F1)
As 0 multiplied by anything is always zero then this only sums the columns preceded by a 1.

Resources