Paste subsequent values in excel with condition - excel

I have data in an Excel sheet as:
Column A Column B
1 1
5 5
6 6
50 50
.. 51
.. 52
.. 53
1 1
5 2
6 6
50 50
.. 51
.. 52
.. 53
very long list
I want to fill Column B corresponding to Column A as shown above that if cell A is not blank then cell B will have same value as A ..and if Cell A has value 50, then next blank rows in column B will have subsequent values after 50 ..
I tried to make formula
=IF(A2="",IF(A2=50,50,VALUE(A1)+1),A2)
and pasted in Cell B2 and dragged but it is giving me wrong results:
5
6
50
51
1
1
..
Can anyone please suggest? Thanks in advance.

This assumes your data starts in row 2. Paste in B2 and fill down.
=IFERROR(IF(A2<>"",A2,IF(OR(AND(A2=50,A3=""),B1>=50),1+B1,"")),"")
This works on your use case, but it's all kinds of kludgy so might not extend well to other cases.

You can simply paste in B2
=IF(ISBLANK(A2),B1+1,A2)
and then copy the formula by dragging it down
Outcome:
A B
---------
1 1
5 5
6 6
50 50
51
52
53
1 1
5 5
6 6
50 50
51
52
53
Note: it won't work for B1. You have to have enter a value in this cell manually.

Related

Excel MERGE two tables

I have SET 1
CLASS
Student
TEST
SCORE
A
1
1
46
A
1
2
50
A
1
3
45
A
2
1
45
A
2
2
47
A
2
3
31
A
3
1
34
A
3
2
45
B
1
1
36
B
2
1
31
B
2
2
41
B
3
1
50
C
1
1
42
C
3
1
31
and SET 2
CLASS
SIZE
YEARS
A
39
7
B
20
12
C
31
6
and wish to COMBINE to make SET 3
CLASS
STUDENT
TEST
SCORE
SIZE
YEARS
A
1
1
46
39
7
A
1
2
50
39
7
A
1
3
45
39
7
A
2
1
45
39
7
A
2
2
47
39
7
A
2
3
31
39
7
A
3
1
34
39
7
A
3
2
45
39
7
B
1
1
36
20
12
B
2
1
31
20
12
B
2
2
41
20
12
B
3
1
50
20
12
C
1
1
42
31
6
C
3
1
31
31
6
so basically add the SIZE and YEARS columns from SET 2 and merge on CLASS onto SET 1. In excel how you can do this? I need to match on CLASS
Define both sets as tables and “left join” in PowerQuery. There you can choose the columns of the resulting table.
https://learn.microsoft.com/en-us/power-query/merge-queries-left-outer
If you have Set 1 on the top left of a worksheet "Set1" and Set 2 on the top left of a worksheet "Set2", then you can use the formula
=VLOOKUP(A2;'Set2'!$A$2:$C$4;2;FALSE), where $A$2:$C$4 is the range of Set2, and A2 is the class value from Set1, which is what is used to do the lookup in Set2. The next argument, 2, means to take the second row from Set2, and the FALSE at the end means that you only want exact matches on the CLASS. You can do auto-fill with this formula, and do similar steps for the years. If you look up the help for VLOOKUP within Excel, that should help you to understand how it works.
Your first set of data is essentially your primary set of data that you just want to add attribute columns to. I built this example on Google Sheets which should help explain. Using spill formulas, only a few cells are needed with their own formulas. You can see them as they are highlighted in yellow. When you use in Excel, obviously make sure you change the column references, but this would get you the answer.
Note you have to have SpillRange in Excel for this to work. To test, see if you have the formula =unique()
This solution may work for you if both sets start in the same column. As example in my image, both of them start at column A. You can get all data with a single VLOOKUP formula:
Formula in cell E2 is:
=VLOOKUP($A2;$A$22:$R$25;COLUMN($B22);FALSE)
Notice the mixed references at first and third argument and absolute references in the second one. Third argument is critical, because is the relational position between both sets, that's the reason it's easier if both sets start at same column. If not, you'll need to adjust this argument substracting or adding, depending on the case.
Anyways, with a single formula, you can get any number of columns. The only disavantage of this formula is that you need to manually drag to right until you got all the columns (10, 30 or whatever). You'll notice you are done because the formula will raise an error:
This error means you are trying to get a referenced outside of your column area.

AGGREGAT with critiera and duplicates in array

I have the following Excel spreadsheet:
A B C D E
1 ProdID Price Unique ProdID 1. Biggest 2. Biggest
2 2606639 40 2606639 50 50
3 2606639 50 4633523 45 35
4 2606639 20 3911436 25 25
5 2606639 50
6 4633523 45
7 4633523 20
8 4633523 35
9 3911436 20
10 3911436 25
11 3911436 25
12 3911436 15
In Cells D2:E4 I want to show the 1. biggest and 2. biggest price of each ProdID in Column A. Therefore, I use the following formula:
D2 =AGGREGAT(14,6,$B$2:$B$12/($A$2:$A$12=$C2),1)
E2 =AGGREGAT(14,6,$B$2:$B$12/($A$2:$A$12=$C2),2)
This formula works as long as the prices are unique in Column B as you can see on the second ProdID (4633523).
However, once the price is not unique in Column B (for example 50 for ProdID 26026639 and 25 for ProdID 3911436) the functions in Cells D2:E4 does not show the right results.
Do you have an idea if you can solve this issue with the AGGREGAT-Formula and wihtout using an ARRAY-Formula?
you could check number of occurences of the first ProdID-price combinations and use that in the last argument of the AGGREGAT function. So instead of
=AGGREGAT(14,6,$B$2:$B$12/($A$2:$A$12=$C2),2)
you would have
=AGGREGAT(14,6,$B$2:$B$12/($A$2:$A$12=$C2),2+COUNTIFS(A:A,C2,B:B,D2)-1)
of course you can just put "1+COUNTIFS..." but I put it this way so it can be better understood that it uses position 2 + number of occurences of the combination of ProdID with biggest number after the first occurence.

How to paste list of values into cells of same columns based on equal intervals in excel?

Like i have list of some numbers and i wanted to paste those values in cells such as A1 which get first value then A9 get second value similary.
I want solution of this without using macros.
A B C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
The value which I have are:-
87
75
67
74
94
99
98
80
64
65
59
77
97
99
so I wanted that value 87 goes to A1 then 75 goes to A9 then 67 goes to A18 and so on..
Start in B1: =A1 just for the first (your list is in A1:A14 for example)
In B2 write the following:
=IF(MOD(ROW(),9)=0,INDEX($A$1:$A$14,INT(ROW()/9)+1,1),"")
Mod(Row(),9)=0 to test if the row is the 9th after the precedent Value
Int(Row()/9) to get from the list in A the next row
IF to return empty
You can drag it down
When finish copy column B paste special Values in a new column and you can work with it normally

Excel table formulas to return blank

I have a table in excel with 2 columns, the E column is the running total the D column is the input value so normally it would be = E15+D16 however, i want the E column to return a blank if nothing is entered in the D column- what formula do I need?
1 Nov-23 Nov-30 1,230 1,230
2 Dec-01 Dec-07 130 1,360
3 Dec-08 Dec-14 416 1,776
4 Dec-15 Dec-21 124 1,900
5 Dec-22 Dec-28 102 2,002
6 Dec-29 Jan-04 83 2,085
7 Jan-05 Jan-11 95 2,180
8 Jan-12 Jan-18 88 2,268
9 Jan-19 Jan-25 102 2,370
10 Jan-26 Feb-01 130 2,500
11 Feb-02 Feb-08 311 2,811
12 Feb-09 Feb-15
13
14
15
16
17
18
19
20
21
22
=if(D16="","",E15+D16)
You dont even need the ISBLANK, just use empty quotes.
ISBLANK is what you're looking for.
In E16 =IF(ISBLANK(D16), "", E15+D16)
Use If and IsBlank in conjunction.
Do a check to see if the cell is blank, then depending on the result do the sum or the return blank. I don't have excel in front of me atm, but it should go something like this:
=if(ISBLANK(D16), "", E15+D16)
You can drag this down starting from the second cell in the column where this running total lives. The first one is obviously just the value from the adjacent cell.

divide data in one column into more column in excel

i want to do this in Microsoft Excel 2007
This a one column. I have 20098 data in one column like below.
1
2
3
4
5
6
7
8
131
1
31
31
31
31
41
I want to rearrange those data like this how can i do it
1 4 7 1 31
2 5 8 31 31
3 6 131 31 41
If your data was in column A then in cell B1 put
=OFFSET($A1,3*(COLUMN()-COLUMN($B$1)),)
and copy down and right to split your data as desired
use this formula in all 3 rows and 6700 columns of the resulting range:
=INDEX($A:$A;(COLUMN()-first_column)*3 + ROW()-first_row+1)
where first_column is =column(..) and first_row is =row(..) of the cell where you want to have the 1st value
e.g. if you use B1:IWS3 range to list the results, the formula will be:
=INDEX($A:$A;(COLUMN()-2)*3 + ROW())

Resources