repeating rows of data based on specific data in a given group of cells - excel

I have a row of data that contains 40 possible cells of specific data that I need to separate and repeat that row of data with the cell that contains the specific data out the 40 possibilities and then continue to repeat this process until there are no more cells with the specific data.
EqType1 and EqSerial1 would need to be selected together but are in separate cells. this example should return 2 rows of data the first with the FirstName LastName EqType1 EqSerial1 and the second row with FirstName LastName EqType2 EqSerial2 and then stop if there are no more Eq and move on to the next row of data and perform the same function over again.
Sample Row of Data:
FirstName LastName EqType1 EqSerial1 EqType2 EqSerial2
MORGAN TURNBULL ARPCXDT PAX501037020 TG1682G 7823AE179414

"this example should return 2 rows of data the first with the FirstName LastName EqType1 EqSerial1 and the second row with FirstName LastName EqType2 EqSerial2"
A disclaimer: The following will only work if you put your 2 new combined indexes into columns and not rows
If I understand your question correctly, you could try this:
Insert two extra columns at the end of your data: Eq1 and Eq2
So your data would be laid out like this:
A B C D E F G H
1 FirstName LastName EqType1 EqSerial1 EqType2 EqSerial2 Eq1 Eq2
2 MORGAN TURNBULL ARPCXDT PAX501037020 TG1682G 7823AE179414
In cell G2 insert the formula: = A2 & " " & B2 & " " & C2 & " " & D2
In cell H2 insert the formula: = A2 & " " & B2 & " " & E2 & " " & F2

Related

Running Excel query row by row

I have made a following query in excel powerquery:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
IDname = Vir{0}[IDname],
query = "exec procOderBySampleID '"& IDname &"' ",
target = Sql.Database("XXX-YYYY\YY76", "SQLtable", [Query=query])
in
target
It returns result for a first row in IDname column. I would like a query to run row by row and return results for all the values in IDname column. Combining values with comma in between them IDname = Text.Combine(List.Transform(Source[IDname], Text.From), ", "), and passing them to query does not work, so the solution would need to work row by row.
Sample:
A1 IDname
A2 78-001
A3 78-002
A4 78-003
query should run stored procedure for one value after another (A2 then A3 then A4) and return a table:
A1 IDname Refnumber User
A2 78-001 4 Mat
A3 78-002 7 Kid
A4 78-003 5 Luc
With current code I only get A1 and A2 as result.

Pick unique random values and join them in one cell in excel

I have excel sheet with data, ex: is bellow
A B
Text 1 Text 3 Text 1 Text 5
Text 2 Text 6 Text 9 Text 7
Text 3 Text 2 Text 4 Text 8
Text 4
Text 5
Text 6
Text 7
Text 8
Text 9
I want to joint column A value in column B randomly but values must unique (no repeat same value ). As you can see in my above ex: column A values random joint in column B . i search on internet unable to find any formula or answer. im new so dont now which formula work for this.
In C1 enter:
=RANDBETWEEN(1,9)
In C2 enter:
=LARGE(IF(ISNA(MATCH({1;2;3;4;5;6;7;8;9},$C$1:C1,0)),{1;2;3;4;5;6;7;8;9}),RANDBETWEEN(1,9-ROWS(C$2:C2)))
and copy downwards.
Column C represents a randomization of the digits 1 through 9 (with no repeats).
Then in B1 through B3 enter the formulas:
=INDEX(A:A,C1) & " " & INDEX(A:A,C2) & " " & INDEX(A:A,C3)
=INDEX(A:A,C4) & " " & INDEX(A:A,C5) & " " & INDEX(A:A,C6)
=INDEX(A:A,C7) & " " & INDEX(A:A,C8) & " " & INDEX(A:A,C9)

How to use vlookup if lookup value contains multiple values in single cell

Suppose Sheet1 has the following table ( data range Cell A1 to B4)
Fruits | Colors
======= | =======
Apple | Red
Mango | Green
Banana | Yellow
Suppose in sheet2, Cell A1 has following values ( Apple Mango Banana) separated based on space.
How to use VLookup in Cell B2 based on A1 value which can give you the results in the same order ( Red Green Yellow)
This formula in Sheet2!B2 does it:
=INDEX(sheet1!B:B,MATCH(TRIM(LEFT(SUBSTITUTE(A1, " ", REPT(" ", 100)),25)),sheet1!A:A,0)) & " " &
INDEX(sheet1!B:B,MATCH(TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",100)),100,25)),sheet1!A:A,0)) & " " &
INDEX(sheet1!B:B,MATCH(TRIM(RIGHT(SUBSTITUTE(A1, " ", REPT(" ", 100)),25)),sheet1!A:A,0))
This formula works fine when you have 3 values to match (in case there are 2 only, the second one will be repeated). It can be further complicated to treat any number of values.
Of course it can be simpler in VBA using the Split function, and it would take into account any number of keys, yielding the joined values. You can use this in a macro:
Sheet2.Range("B1").value = Join(Application.index(Sheet1.Columns("B"), _
Application.match(Split(Sheet2.Range("A1")), Sheet1.Columns("A"), 0)), " ")
Of course you can adjust it to any cell in column B, using Range("B" & i) and Range("A" & i)...

Check for string in text column A, return another string in column B - Excel

I am trying to lookup one of 3 strings (Blue, Red, Green) in column A. In column A I have:
row1: "Robert has Blue shorts"
row2: "Maria has a Red dress"
row3: "John has a Green car"
Whenever I find one of those 3 words in column A, I want to populate column B with the found instance (Green, Red, Blue).
There will always be one of these 3 words in column A, never more than one and the position of the words can be anywhere in the string.
I know how to put this in Python or SQL but I am struggling with Excel.
Can anyone share a solution if they used this in past?
You can use this array formula:
=INDEX({"Red","Blue","Green"},MATCH(TRUE,ISNUMBER(SEARCH({" Red "," Blue "," Green "}," " & A1 & " ")),0))
Being an array formula it must be confirmed with Ctrl-Shift-Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.
As a note:
You can also replace the {"Red","Blue","Green"} with a range reference. So if the three words were in D1:D3 the formula would be:
=INDEX($D$1:$D$3,MATCH(TRUE,ISNUMBER(SEARCH(" " & $D$1:$D$3 & " "," " & A1 & " ")),0))

How can excel highlight matching entries between 2 tables/4 columns

I am trying to find the duplicates between Table 1 and Table 2. The entires in column 'A' and 'B'together has to match the entries in column 'C' and 'D'
Looking for a formula that will highlight the duplicates in the given scenario.
![Table 1 has 2 columns, A and B. Table 2 has two columns, B and C. The formula should highlight the text in A and B together to text in B and C together][using excel]
Maybe create "key" columns to make things easier: Column X = A & B, Column Y = C & D
Then you can either use vlookup(A&B,Y...) or vlookup(C&D,X...)
Or Match(A&B, Y...( etc will give you the row number which could be useful, plus is a lot quicker than vlookup if you have heaps of rows (plus you don't need to lookup anything so why not? Or even if you did Index(Match..)) is still quicker...
Or you could even use Countif(A&B, Y) and vice versa...
Thats a hell of a lot of pseudo formulas lol so maybe something like:
Sheet2.D1 Formula: "=CountIf(Sheet1!$C$1:$C$1000, A1 & B1)" and do the same on the other:
Sheet1.D1 Formula: "=CountIf(Sheet2!$C$1:$C$1000, A1 & B1)"
Sheet1!C1 Formula = "=A1 & B1"
Sheet2!C1 Formula = "=A1 & B1"
Or if you only have one duplicate and want to know the row number:
Sheet1.D1 Formula: "=If(isna(match(A1 & B1,Sheet2!$C$1:$C$1000,0)),"","Duplicate on row: " & match(A1 & B1,Sheet2!$C$1:$C$1000,0))"

Resources