Search for a word in column and then copy row - excel

I have two tabs - the ALL tab and CATA tab.
ALL tab has all the data (source)
CATA tab is the target tab where specific rows have to be pasted.
Question:
I want to search all rows one by one,
then copy rows from source tab where the column I has CATA word in it
and then paste that row to the target tab.
Sample data for column I:
"USTA;#CATA;#INTA;#Non-TA"
"USTA;#INTA;#Non-TA"

I would suggest using an approach as described below:
Insert a filter on the whole table, and filter on column I on Text > Contains and type "CATA" in the entry box.
Copy everything except column A then paste in the tab CATA.

If the number of rows that match is unknown and you don't want blank rows in between, this will produce a subset of the rows that contain the phrase "CATA" in Column A.
This is the formula for cell A2 that can be dragged down as far as needed:
=IFERROR(
INDEX(ALL!A:A,
SMALL(
IF(
NOT(ISERROR(FIND("CATA",ALL!A:A))),
ROW(ALL!A:A)),
ROW()-ROW($A$1))),"")
It must be entered with CTRL+SHIFT+ENTER.
It will display a blank row once all the possible CATA rows have been found.
For Column B, it changes only by two references (A:A becomes B:B):
=IFERROR(
INDEX(ALL!B:B,
SMALL(
IF(
NOT(ISERROR(FIND("CATA",ALL!A:A))),
ROW(ALL!B:B)),
ROW()-ROW($A$1))),"")
You may replicate this for as many columns as need to be transferred. Don't forget to start entering it in Row 2, and be sure to enter the first one with CTRL+SHIFT+ENTER before dragging it down the column.

Related

Excel not deleting all selected rows

I have a spreadsheet with a couple hundred rows, and some of the cells contain the text "N/A". I'd like to delete the full row of any cell that has "N/A" in it.
My first thought was to use Find All and then once all the relevant cells are selected, I can do Ctrl - and select "entire rows". However this usually leaves a bunch of cells with "N/A". Why is this?
Insert a column (or use last available blank column).
Use equation IFERROR(SEARCH("N/A", A2),"No Match") where I am
assuming Column A has your strings that may contain N/A
Drop Equation down to used range
Filter your new helper column and remove No Match
Delete rows of visible cells
Output below. Any numeric value in Column B means a match of N/A was found.

How to apply formula to a whole column?

I need to subtract the minimum of that column from all rows of the column in Excel. I have one million rows and I cannot drag the right corner of the cell box all the way down to apply the formula to all those cells. I unfortunately haven't found anything that works. I want to subtract the minimum of a column from each cell of that column divide by 1000 and store in another column:
=(B1-MIN(B:B))/1000
How do I apply this to all rows of the column where I want this to work?
How do we apply formulas in general to all rows of a column in general?
Several ways to apply a formula to a new column in a large data set:
Option 1 - turn the data into a table: Assuming the data has headers, select the data and hit Ctrl-T or use Insert > table and tick the box "My table has headers". Now enter a name for the new calculated column and below the header enter the formula. It will automatically be applied to all rows in the table.
Option 2 - Enter the formula in the first row of next empty column of the data range. Then double click the fill handle (the lower right-hand corner of the selected cell) to fill the formula all the way down to the last row of the data range
Option 3 - Select the cells where the new formula should go. Easiest might be to start at the bottom end of the data and use Ctrl-Shift-up arrow to select up to the top. Adjust the selection to suit and hit Enter or Shift-Enter to make the top cell the current cell. Enter the formula and confirm it with Ctrl-Enter. It will be applied to all selected cells.
Copy the column, say it's A. In a couple of spare cells enter:
=MIN(A:A)
and
1000
Copy the formula cell, Paste Special..., Values over the top. Copy that cell, select the copy of ColumnA, Paste Special..., Operation Subtract. Copy the cell containing 1000, select the copied column, Paste Special..., Operation Divide. Filter ColumnA to select blanks and delete the contents on the copied column for the selected rows.

Excel - logic for skipping rows in a formula

I am trying to do the following via a formula rather than VBA/macro (i do not want a copy/paste special solution as i need more control). is it possible to:
I have a column in which there are some blank rows and some rows with values. let's call that column A. In column b, i only want to copy the cells if the column A has a value. if it doesn't, i want it to skip to the next cell in column A, but stay on on the same cell for column b.
Column A
1
2
[blank]
4
[blank]
6
i want column b output to be (but with no blank rows). this would imply that somehow the formula would need to loop and have some loop skipping logic:
1
2
4
6
Normally i would just set cell B1 = A1 to copy it over, but since i want to skip rows that are blank in column A, i'm not sure what to do besides right a macro. Can i use an array or any other creative solution? Eventually, i would also use this for items with specific values (not just blanks).
thanks!
Generically in cell C2 copied down....
=IFERROR(INDEX(Range,SMALL(IF(Range=criteria,ROW(Range)-MIN(ROW(Range))+1),ROWS(C$2:C2))),"")
confirmed with CTRL+SHIFT+ENTER
so here if your data is in A1:A10 and you want results from B1 down
=IFERROR(INDEX(A$1:A$10,SMALL(IF(A$1:A$10<>"",ROW(A$1:A$10)-ROW(A$1)+1),ROWS(B$1:B1))),"")
confirmed with CTRL+SHIFT+ENTER and copied down
when you run out of data you get blanks
For BLANKS, just copy ColumnA to ColumnB, select ColumnB, Find & Select, Go To Special..., Blanks, right-click one of the selected cells, Delete... with Shift cells up.
If you don't care about the ordering of the numbers (such as an array that will be binned or analyzed with a histogram), then simply copy the row and paste values only in another row. Now just sort the row of values. It will place all the empty cells at the bottom of the selection.

Sort row data into columns with same heading in excel 2010

Put simply, I need to sort row data for a specific range into the correct columns based on that columns heading. For example, if there are five columns labelled A through E, and data in the rows below ranging from A through E; I need all of the A's to be in the A column, all of the B's in the B column etc.
Example start data:
How it should look after the sort:
It also must be able to work with the possibility of having empty cells. For example; if the first example data had no B in row 3, the data must not shift over to the left so that C is in the B column etc.
Other info: not feasible to do by hand - over 450 rows.
It also must be able to work with the possibility of having empty cells.
Taking the above into consideration.
NON VBA WAY
Insert enough columns so that the data moves to the right
Next in the row one, duplicate the values from your data
Next in Cell A2 Put this formula
=IF(COUNTIF($H$2:$L$2,A1)>0,A1,"")
Copy the formula to the right
Next remove "$" from the table range and add it to the header in formula in Cell A2 so that we can copy the formula down. This is how it would look
=IF(COUNTIF(H2:L2,$A$1)>0,$A$1,"")
Similarly your B2 formula will look like this
=IF(COUNTIF(H2:L2,$B$1)>0,$B$1,"")
Change it for the rest
How highlight cells A2:E2 and copy the formula down.
Your final Sorted Data looks like this.
Copy columns A:E and do a paste special values on Col A:E itself so that the formulas change into values and then delete Cols H:L

Inserting row alternatively in an excel sheet

I have an excel sheet which looks like this:
I want to insert row(or cell) below every filled cell. Like this:
I have thousands of records so need to do this automatically. How can I achieve this?
Thanks in advance!
A non-VBA approach would be to make a new sheet, and enter this formula in A1:
=INDEX(Sheet1!A:A, ROUNDUP(ROW(A1)/2, 0))
Then select A1 and A2 (leaving A2 blank), copy it, select twice the number of rows as in Sheet1, and paste.
If you only want values, you could then select column A and copy, then paste special and paste values only.
You could do it in VBA with the following code:
Sub doIt()
Dim numRows As Long
Dim i As Long
numRows = ActiveSheet.UsedRange.Rows.Count
For i = numRows To 2 Step -1
ActiveSheet.Rows(i).Insert Shift:=xlDown
Next i
End Sub
select the raw that contains the data you want to separate by 1 cell at a time.
press F5.
click special.
at the Go to Special dialog box, click "Constant".
right click 1 of the selected cell and insert
Alternatively, I found the following solution from https://www.pcmag.com/article/149833/insert-alternate-blank-rows-in-excel
You can create the blank rows separately and then interleave them with the existing rows by sorting. To start, insert a new column to the left of the existing column A. Enter 1 in cell A1 and highlight column A all the way to the last row that contains data. From the Edit menu select Fill | Series and click on OK. Column A should now contain numbers from 1 to the total number of rows. Press Ctrl-C to copy these cells to the clipboard, click in the cell just below the last of them, and press Ctrl-V to paste. Now highlight the entire data area, including the new rows with just a number in column A. Select Sort from the Data menu and choose the No header row option in the resulting dialog box. Under Sort by select Column A, under Then by select column B, and click on OK. Finally, delete column A. You now have a blank row after every one of the original 1,000-odd rows.
Because blank lines can often cause problems with charts or calculations, you may want a quick way to remove them. You can use a similar technique.
Again, insert a new column to the left of column A and fill a series from 1 to the end of the data. Highlight the entire data area and sort by column B (the first column of real data). This will group all of the blank rows together. Next, highlight the data area again, and re-sort by column A. The blank lines are gone, and your data is restored to its original order. Finally, remove column A.
easy way:
in a free column (example is column A) fill the first 3 rows with 2,4,6
auto fill the column down to the end of your data.
At the end, fill the next 3 lines with 1,3,5
Autofill down the same amount of lines your data is
now select all, data-> sort-> A
wich will sort your data to 1, (empty) 2 (data) 3 () empty
;)

Resources