Is there a formula that inputs on nth row of column A by reading what's in column F and/or D on their congruent rows? - excel

I'm very new to excel programming. Currently I'm working on an excel worksheet and I need a formula that inputs on nth row of column A by reading what's in column F and/or D on their congruent rows. So far I have something like:
=IF(AND(D:ROW(n)=0,F:ROW(n)="x"),A:ROW(n)="e",IF(D:ROW(n)=0,"N","X"))
e.g.
A B C D E F
1 e 0 x
2 N 0
3 X 2

Put this in A1:
=IF(D1 = 0,IF(F1="x","e","N"),"X")
And copy down.
The references are Relative, so as the formula is copy/dragged down they will change on their own.

Related

How to return row based on all searched instances of a value in a Table excel

I have a very large table with repeating values based off of a ID column. I'm after a function/combination of excel functions that would work to return the ID number where all instances of a searched value are met?
I dont have access to the "Filter" function so im looking for an alternative to this.
E.g, I wish to find all instances of F in the table. From here the function should return the row/associated "ID"
This would then output 2,4,25 where the matches in the table occur
ID
B
C
D
...
BB
BC
SEARCH
F
1
A
B
C
D
E
G
2
D
E
G
F
G
S
3
T
V
A
K
H
E
4
Y
F
J
N
R
K
5
I
O
W
H
X
Z
...
25
T
K
Q
E
H
F
array formula:
=IFERROR(INDEX(A:A,SMALL(IF(B$1:G$500="F",ROW($1:$500)),ROW(A1))),"")
You can try creating an extra column at the end and use this formula in each cell down that column. Make sure your "Search Cell" remains same in the formula though:
Drag this down from first cell down to all rows but make sure the search cell remains same. i.e. B1 in my example. I have added a last extra column H in my example to do this calculaton and the result:
=IF(IFERROR(MATCH(B1,B2:G2,0),"")<>"",A2,"")

Return Multiple Unique Matches in Excel without Array Formula

Given an Excel table of shape
Col. A Col B Col. C Col. D Col. E
x 2 x 2 3
x 3 y 7
y 7 z -5
x 2
z -5
I want to return the first unique hit in Column B for argument "x" in Column D,
the second unique hit in Column B for argument "x" in Column E and so forth.
The formula I'm currently using in cell D1 for this is
{=IFERROR(INDEX($B$1:$B$5,MATCH(0,COUNTIF($C1:C1,$B$1:$B$5)+($A$1:$A$5<>$C1),0)),"")}
which is working.
The problem I'm having is that since this is an array formula and since I'm analyzing a decent amount of data computation time for my sheet is too high.
Is there an alternative for this functionality avoiding an array formula?
Thanks!
Haven't got time to test this properly, but if you have Excel 365 you can use a single formula per row and it may be faster:
=TRANSPOSE(UNIQUE(FILTER(B1:B10,A1:A10=C1)))
in D1.
EDIT
To pull the formula down, you need static references as OP has pointed out. Probably should check for empty cells in column C as well, so formula becomes:
=IF(C1="","",TRANSPOSE(UNIQUE(FILTER(B$1:B$10,A$1:A$10=C1))))

Sorting columns with gaps in Excel / Google Sheets

I'd like to sort several columns in google sheets, but with gaps where there are no matching values in other columns present.
See my example:
Start:
c a z
a k d
d x f
e b m
x e b
Sorted:
a a
b b
c
d d
e e
f
k
m
x x
z
So, is this possible in google sheets and/or Excel? I would prefer google spreadsheets if possible.
For Google Sheets try the formula:
=ArrayFormula(IFERROR(VLOOKUP("r"&ROW(INDIRECT("A1:A"&COUNTUNIQUE(INDIRECT(myRange))))&"c"&TRANSPOSE(ROW(INDIRECT("A1:A"&COLUMNS(INDIRECT(myRange))))),{"r"&VLOOKUP(SORT(TRANSPOSE(SPLIT(CONCATENATE("_"&"_"&INDIRECT(myRange)),"_"))),{UNIQUE(SORT(TRANSPOSE(SPLIT(CONCATENATE("_"&"_"&INDIRECT(myRange)),"_")))),ROW(INDIRECT("A1:A"&COUNTUNIQUE(INDIRECT(myRange))))},2,0)&ARRAY_CONSTRAIN(SORT({TRANSPOSE(SPLIT(CONCATENATE("_c"&COLUMN(INDIRECT(myRange))*ROW(INDIRECT(myRange))^0),"_")),TRANSPOSE(SPLIT(CONCATENATE("_"&"_"&INDIRECT(myRange)),"_"))},2,1,1,1),ROWS(INDIRECT(myRange))*COLUMNS(INDIRECT(myRange)),1),SORT(TRANSPOSE(SPLIT(CONCATENATE("_"&"_"&INDIRECT(myRange)),"_")))},2,0)))
To make it work first make named range called myRange and paste there an address of desired range:
Please see my sample file with the solution.

How to sort 3 columns of data in excel

I'm using Microsoft Excel 2011 on a Mac, and I need help sorting 2200 rows of data.
Basically, what I want to do is to sort the Type column, while keeping its corresponding data beside it after the type is shifted.
I would like all the type A's, B's, and C's to be in order, and have their adjacent data from experiment 1 and 2 follow to the new position once sorted.
Each data group is separated by a few empty rows.
Here's a small example of what my data looks like:
Type EXPERIMENT 1 EXPERIMENT 2
A A F
F R
S S
E G
B Y A
A A
S H
F
A A E
D F
F S
E
Y
A F H
R G
E A
D F
Y W
S E
S
C F S
D D
S U
F J
Y
T
And this is what I want:
Type EXPERIMENT 1 EXPERIMENT 2
A A F
F R
S S
E G
A A E
D F
F S
E
Y
A F H
R G
E A
D F
Y W
S E
S
B Y A
A A
S H
F
C F S
D D
S U
F J
Y
T
In an unused column to the right (aka Helper column) put this formula into the second row.
=VLOOKUP("zzz",A$1:A2,1)&TEXT(COUNTIF(A$1:A2,VLOOKUP("zzz",A$1:A2,1)),"0000")
... and fill down as necessary. Select all of the columns and sort with the Helper column as the primary sort key. The results from your sample should mirror the following.
                 
Additional formulas can be provided if you need sorting key criteria on the Experiment x columns. Show what you've tried together with some example of the results expected and additional assistance will no doubt be offered.
It seems to me it would be easy to sort if you would concatenate each data set into a row. Type goes in column A; Exp 1 into one cell in column B; Exp 2 into one cell in column C. Then the sort is simple. Otherwise you'll require a complicated macro. You can always parse it out later if required.
To concatenate you'll need to:
Save as new workbook first to avoid changing your original data
Insert a row between the headers and the first data
Put the formulas indicated into row 2 and copy down
Copy and PasteSpecial as values
Sort by column D
Delete all rows that are false
Now your sorting will be easy.
Edit: fixed my formulas to line up with true column.

Return value of last populated cell in variable range

Into column D, I'd like to copy the value from the last cell with data in columns E up until the column with the header "DETAIL". There might be anywhere from 2 to 15 columns from E until the column with that header, so that's where I'm stuck. So to be clear, an example:
A B C D E F G H DETAIL
1 x x x a b c d x
2 x x x x
3 x x x c b a x
3 x x x d c x
Should fill column D like so:
A B C D E F G H DETAIL
1 x x x d a b c d x
2 x x x x
3 x x x a c b a x
3 x x x c d c x
I don't mind handling this with a formula (which I couldn't come up with) or programmatically.
Create a dynamic named range by pressing CtrlF3 to bring up the Name Manager, click New, name the range something (I chose MyRange) and then use this formula to define it (Note you may need to change the Sheet name):
=Sheet1!E2:INDEX(Sheet1!2:2,MATCH("Detail",Sheet1!$1:$1,0)-1)
Then, in cell D2 and copied down, use this formula (I did not use IFERROR so that it would be backwards compatible):
=IF(COUNTA(MyRange),INDEX(MyRange,MATCH(REPT("z",255),MyRange)),"")
Here are the results (highlighted) using your provided sample data:
Please try:
=IFERROR(INDEX(F2:T2,,MATCH("zzzzzz",F2:T2)),"")
in D2 and copied down to suit.
Try using LOOKUP:
=IFERROR(LOOKUP(9^99,SEARCH("*",E1:H1),E1:H1),"")
SEARCH("*",E1:H1) returns a number when it matches any character and an error when the cell is blank. LOOKUP then returns the contents of the cells of the last number smaller than 9^99 in the array generated by SEARCH.
For example, in the first row, SEARCH("*",E1:H1) returns {1,1,1,1} so that LOOKUP returns the last 1, being d.
In the third row, SEARCH("*",E3:H3) returns {1, 1, 1, #VALUE!} and LOOKUP returns the last 1, which is a here.
This formula will work with numbers and text alike. The downside is that it is considered slower than INDEX/MATCH. On the other hand, you can modify the INDEX/MATCH to work with numbers, or modify it to work for both but becomes an array formula:
=IFERROR(INDEX(E1:H1,,MATCH(1,SEARCH("*",E1:H1))),"")
[Works with Ctrl+Shift+Enter, otherwise returns an empty cell with Enter alone]

Resources