Skip a chosen ratio of cells in Excel - excel

I have tried to:
Take item 1 from List A and put it in row 1.
Then put item 2 from List A in row 11.
Then put item 3 from list A in row 21 (etc.)
Then I tried to do the same with List B but:
Item 1 from List B to row 2.
Item 2 from List B to row 12.
Item 3 from List B to row 22 (etc)
How do I tell Excel to fill the cells in this ratio?

I have a solution but it involves inserting a column before both columns A & B
If you insert a column and put 1 in A1 and then the formula =A1+10 in cell A2 and fill down, you will have your row ratio 1,11,21,31. Do the same for column B but start with 2 in cell C1 and enter the formula =C1+10 in C2 and fill down.
Now that you have the destination row number next to your data, you can use a vlookup to pull the correct data into the correct row.
cell E1 =iferror(vlookup(Row(),$A$1:$B$20,2,false),"")
cell F1 =iferror(vlookup(Row(),$C$1:$D$20,2,false),"")
or you could combine them in the same column using
=iferror(vlookup(Row(),$A$1:$B$20,2,false),iferror(vlookup(Row(),$C$1:$D$20,2,false),""))

Related

Transpose single column to array of unique rows

I'm trying to get a list of values that contain duplicates into unique rows.
Column A
Cell 1
Cell 2
Cell 3
Cell 1
Cell 2
Cell 3
Cell 1
Cell 2
Column A
Column B
Column C
Cell 1
Cell 1
Cell 1
Cell 2
Cell 2
Cell 2
Cell 3
Cell 3
I've tried using
=TRANSPOSE(UNIQUE(A1:A3,TRUE,TRUE))
But any combination of the formula removes the duplicates and I want to maintain them.
with MakeArray:
=LET(
rng,A1:A8,
u,UNIQUE(rng),
MAKEARRAY(
ROWS(u),
MAX(COUNTIF(A1:A8,u)),
LAMBDA(a,b,
IF(COUNTIF(A1:A8,INDEX(SORTBY(u,COUNTIF(A1:A8,u),-1),a))>=b,
INDEX(SORTBY(u,COUNTIF(A1:A8,u),-1),a),
""))))
This will expand automatically to any number. It will also put the ones with the most duplicates at the top so it is an inverted pyramid:
Alternatively, you can try:
Formula in C1:
=IFERROR(DROP(REDUCE(0,UNIQUE(TOCOL(A:A,1)),LAMBDA(x,y,VSTACK(x,EXPAND(y,1,COUNTIF(A:A,y),y)))),1),"")
Or, with a build-in sort function:
=SORT(IFERROR(DROP(REDUCE(0,UNIQUE(TOCOL(A:A,1)),LAMBDA(x,y,VSTACK(x,EXPAND(y,1,COUNTIF(A:A,y),y)))),1),""),1)

Jump to the next non-empty cell and use lates value in the list

I have the following Excel spreadsheet:
A B Desired Result Column B
1 Product A 50 **50** **50**
2 Product B =IF(A2="","",B1) 50 50
3 =IF(A3="","",B2)
4 Prodcut C =IF(A4="","",B3) 50 **40**
5 =IF(A5="","",B4)
6 ="" =IF(A5="","",B5)
7 Product D =IF(A5="","",B6) 50 40
8 Product E =IF(A5="","",B7) 50 40
** Input of User
In Column A there is a list of different products. As you can see there can either be empty cells or cells with formula ="".
In Column B I want to achieve that the last value before the first empty cell or ="" cell applies to the other rows.
For example: If I enter a 50 in Cell B1 I want to achieve that this 50 appears next to every product and empty cells or ="" are ignored.
I can achieve this with the following formula:
=IF(A2="","",$B$1)
Now the problem is, that the user can also type a different number in another cell in Column B. For example he could type in a 40 in Cell B4.
In this case I want that the 40 applies to all other following rows instead of the 50 as you can see in the section "Desired Result Column B" in the example above.
How do I have to change my formula in Column B to achieve this?
Enter the following formula in Cell B2
=IF(A2<>"",INDEX($B$1:$B1,MAX(IF($B$1:$B1<>"",1,0)*ROW($B$1:$B1))),"")
Drag/Copy down as required.
This is an array formula so commit it by pressing Ctrl+Shift+Enter.
Try:
B2: =IF(A2="","",LOOKUP(2,1/LEN($A$1:A1),$B$1:B1))
With the addressing mode used in the LOOKUP formula, it will examine the rows up to the row before the lookup. If the column A value is not blank, lookup_vector will match the last non-blank cell in column A prior to the row containing the formula, and result_vector will return the value in the same row in column B.
It is rather critical that your user entries are restricted as you have described above.
If the user can make an entry in column B that does NOT correspond to an entry in column A, and you want that entry to be copied down, then use:
=IF(A2="","",LOOKUP(2,1/LEN($B$1:B1),$B$1:B1))
Also, note that the sequence will be upset if the user deletes an entry in column B, instead of replacing it with another number. The formulas below the deletion will interpret the deleted value as a zero.

Combining data in excel

Dears,
I have 4 columns in excel.
Each row have two values but also it is mapped to another row.
I'd like to sum the values from these the rows that are mapped and delete the extra rows.
Example attached: Row A has two values but also mapped to Row C. I want to add the values in Row A with the ones in Row C and keep Row A and delete Row C
Is it possible to use formulas instead of VBA as I don't have experience in VBA?
Please advise.
Assuming your Keyword data starts with A2 and Value 1 starts with B2 and Value 2 starts with C2. (Please refer the snap below)
Apply the below formula in H2 for Value 1 summing and drag down
=IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,2,FALSE),VLOOKUP(G2,$A$2:$D$4,2,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,2,FALSE))
Apply the below formula in I2 for Value 2 summing and drag down
=IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,3,FALSE),VLOOKUP(G2,$A$2:$D$4,3,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,3,FALSE))
EDIT #1 If G value does not contain in Table 1 then apply the below formula
in H2
=IF(ISERROR(IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,2,FALSE),VLOOKUP(G2,$A$2:$D$4,2,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,2,FALSE))),"Not Found in Table",IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,2,FALSE),VLOOKUP(G2,$A$2:$D$4,2,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,2,FALSE)))
in I2
=IF(ISERROR(IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,3,FALSE),VLOOKUP(G2,$A$2:$D$4,3,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,3,FALSE))),"Not Found in Table",IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,3,FALSE),VLOOKUP(G2,$A$2:$D$4,3,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,3,FALSE)))

Creating unique ID numbers for duplicate Excel rows

I have an Excel spreadsheet with multiple columns. I'd like to automatically add unique ID numbers (starting in cell A2) to duplicate values in column D (starting at D2). Any way to make the spreadsheet look like below? Thanks.
Column A Column D
1 3
1 3
2 Bard
2 Bard
3 4ton
3 4ton
3 4ton
In A1 enter 1
In A2 enter:
=IF(D1=D2,A1,A1+1)
and copy down.
It's not clear on whether your data table has column header labels or not but this formula should not make a difference beyond having to pre-populate A1 if there is no column header label.
In A2 use this formula,
=IFERROR(INDEX(A$1:A1, MATCH(D2, D$1:D1, 0)), MAX(A$1:A1)+1)
Fill down as necessary. Your results should resemble the following.
        
While your column D was sorted, that is not a requirement with this formula.

how to search for two consecutive cells that have 2 different values?

Because I am working with a very large sheet of excel and i need to find in a specific column the last 1 before changing to 0.
is there a way to search for that ?
how to search for two consecutive cells that have 2 different values ?
If your values are in column A, put into B2:
= A2 = A1
Copy B2 and paste to the rest of column B, from B3 to next to the last value in column A.
Search column B for FALSE.

Resources