Inserting row alternatively in an excel sheet - excel

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
;)

Related

Selecting every 3rd row in excel

I am looking to select every third blank row in excel. Once I do that, I need to enter a formula into this third blank row that extracts the contents of a cell below. I would like to have it so this will be done for every third blank. A macro would be fine, I am just not familiar with VBA code so I am not sure where to start.
You'll notice that every third blank row contains the ID from column a in the row below it, and the name from column g below the third blank. Any ideas of how this can be done efficiently?
Just add a column which repeats every 3 rows and filter on that!
You may also be looking for Pivot Tables
Add two columns before column "A", so that your id column becomes column "C".
Now fill all cells with value 1 till the last of your data range in column "A".
In cell "B1" use below formula & fill down till your data
=ISNUMBER(D1)
Now add filter ( Ctrl + Shift + L ). And filter data in column "B" with "FALSE"
If you can follow these steps exactly, you will get all rows you want.
Then use this formula in Than apply filter.

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 - copy row which have non-blank cell to another tab

I need to make this situation happened:
Let's say I have three different tabs, let's call them Atab, Btab and Sum.
In Atab and Btab I have rows of information. In column K, I have a "comment column".
If the comment column in some row is not blank (it has a comment) - I want the whole row to be coppied to Sum tab.
So in the Sum tab I will see all of the rows of Atab and Btab with comments (on K column).
Is it possible? :)
I want the whole row to be coppied to Sum tab.
I'm assuming you mean “the sum of the Atab and Btab should be placed in Sum tab” and with tab you mean a cell. Then the task is easy, use this formula:
=IF(K1<>""; SUM(A1:B1); 0)

Search for a word in column and then copy row

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.

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

Resources