Comma separated value to columns in Excel - excel

I have multiple comma separated rows in excel with drugs name
e.g.
1) drug1,drug2,drug3,drug4
2) drug1,drug2,drug3,drug5
3) drug1,drug2,drug5,drug6
What I want to do is make these rows column such that all these rows distinct values becomes column. So in our case drug1,drug2,drug3,drug4,drug5,drug6 will become column and in rows they should have 0 if that row doesn't have that drug and 1 if it has that drug in that row.
Any help will be appreciated.

Here's a screenshot of how I would do it in multiple steps.
split the data text to columns (data menu, text to columns)
copy data into a single column (B) (copy range B2:E4) into B10, then copy out of C10-End of range and put back into B13 etc) (and have 2 columns one for rowID and one for value
For rows 10,11,12 manually 1-3. copy and paste using ctrl-down arrow to fill in each series until all filled in .
generate pivot Table (layout included now.)
This is assumign this is a one time thing and throw away. If this has to be done repeatedly I'd macro it.

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.

copy the next column values and paste to the previous column

I have 20 columns of values in excel sheet and each has two 12 rows, i want to cut the values of the second column values and paste in to the first column 13th row and then cut the values of third column and paste in first column 25 row and so on
Instead of cutting and pasting it can be easier to create beside a new table with the desired layout using formula
(reference to the desired cell). You can then copy/paste value .

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

Copy row to new sheet if numeric value in column differs from row to row (every two rows compared)

I have two tables combined where in every ODD numbered row (1, 3, 5....633), it contains the values of my MAIN table (that's in red in my attached screenshot).
The EVEN rows are from a USER table that needs to be updated (that's in blue in my screenshot).
The numeric string that's in column B is the key value that I'm using for my comparative value. For every numeric value in the ODD row that is different to the one beneath it in the EVEN row, I want that ODD row (in Red) copied to a new sheet. If you notice that column A is a repeating numeric value for every TWO rows (that's a loan number and that record needs to be updated with those numeric values that are different in Column B)....this will be the project once all the differentiating rows are identified.
For instance, in the screenshot, row #359, 361, 363, etc., would be copied to a new sheet because the value in Column B in the even row beneath it is different
Screenshot
Are you looking to do this manually, with formulas, VBA? If you're familiar with VBA, I'd suggest using the macro recorder in the following way:
add a formula to check the odd/even values =OR(B1=B2,MOD(ROW(),2)=0) (this formula will only return FALSE on ODD rows where the value of the row below differs)
filter on FALSE
select the visible (filtered) cells
copy and paste the cells into the new sheet
I hope this helps. Let us know what works!

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