Choose next non-empty cell in Excel - excel

I have a table (Table A) containing 96 rows with data in them. There's a second table (Table B) that references Table A. In Table B there is a calculation that either copies the data from Table A or puts "" because the data is outside of a specified range (e.g., IF(A1<500,A1,""). The end result in Table B is several rows without data in them.
I'd like to create a Table C that references Table B, but only copies rows with data in them. E.g., if the data in Table B looks like this:
465
461
168
46
187
198
48
I'd like Table C to look like this:
465
461
168
46
187
198
48
Is there way to do this with a formula?
Thanks! Nikki

Use this:
=IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW($A$1:$A$20)/($A$1:$A$20<500),ROW(1:1))),"")
This will skip the blanks as it is copied down.

Select the range containing blank rows you want to remove.
Click Home > Find & Select > Go To Special.
In the Go To Special dialog box, check the Blanks option.
And then click OK, all of the entire blank rows are highlighted. Then click Home > Delete > Delete Sheet Rows, the blank rows have been deleted from the selected range.
You should try with this post:
https://www.extendoffice.com/documents/excel/2654-excel-dynamic-list-remove-blanks.html

Related

Equation/ sorting to separate one long column of data into separate columns

I have two columns of data in an excel spreadsheet that is listed like, each date has three numbers associated with it. It is shown like this:
1 112
1 123
1 456
2 788
2 989
2 901
What I am trying to do is have the data shown like this:
1
112
123
456
Then in another column next to it have;
2
788
989
901
Okay, this can be done pretty easily/quickly.
First, select your entire column that has # ### and go to Data --> Text to Columns, and choose “Delimited”, then use a “Space” delimiter. This will separate your numbers by the space, so 1 and 2 will be in Column A, and the three digit numbers are in B (or wherever you decide to put them).
Then, just get the unique values from column A. I tend to copy the entire column to a temporary column (or worksheet), then highlight them and go to Data --> Remove Duplicates. Now you have a list of unique numbers. Copy and paste these (transposing) into (for example) column D.
Then, in D2, enter this formula (adjust ranges as necessary) as an array, using CTRL+SHIFT+ENTER:
=IFERROR(INDEX($B$1:$B$6,SMALL(IF($A$1:$A$6=D$1,ROW($B$1:$B$6)-ROW($B$1)+1),ROWS($B$2:$B2))),"")
Here’s a screenshot of the final output:

Removing specific rows in Excel

I have a data set in Excel as shown in the snippet below:
Patient Number Age State
1 20 1
1 20 3
1 20 2
2 35 1
2 35 4
3 62 2
3 62 1
3 62 3
3 62 4
3 62 5
I need to keep the last row of each patient, i.e. I need the dataset to look as follows:
Patient Number Age State
1 20 2
2 35 4
3 62 5
Is there a simple way to do this with Excel? Since the dataset is huge and cannot do it manually
If your data is in A:C columns, you can add another column with the following formula in D2:
=A2<>A3
Fill it down. Apply autofilter, choose False in D column and delete all filtered rows.
Edit:
This solution assumes your data is sorted by A column.
Enter below to D2 and press CTRL+SHIFT+ENTER to make it an array formula:
=MAX(IF($A$2:$A$11=A2,ROW($A$2:$A$11)))=ROW()
Advantage of this formula is PatientNumber column doesn't have to be sorted. Formula will find the last entry for each PatientNumber. See below, added one more row for Patient number 1:
You can easily keep the top entry with Data ► Data Tools ► Remove Duplicates. To keep the last entry, you first need to reverse the order.
In an unused Helper column to the right put a 1 in the top row then select all of cells in that column to the bottom of your data and use Home ► Editing ► Fill ► Series to gain a column of sequential numbers.
Sort your data using that new column in descending order.
Choose Data ► Data Tools ► Remove Duplicates using only the Patient column as the criteria for duplication.
Delete the Helper column as it is not longer needed.
Duplicates are deleted from the bottom up so the first value for each patient will be retained.

Excel VLOOKUP or INDEX MATCH

Lets say I have 3 columns of data
AMOUNT(A) AMOUNT(B) INVOICE(C)
55 49 4541
47 47 1515
42 47 4478
86 12 9993
12 100 1224
5 44 1452
100 4287
99 4444
What I need to check to see if the value in column A matches a value in column B. If there is a match, it will return the value from column C in column D. Now this is easy with a VLOOKUP however I am dealing with 700+ lines and there are multiple amounts that match. INDEX(MATCH) could work but it only returns one value. Is this a VB only problem?
I.E Value 47 exists in column B twice so therefore column D would return both invoice numbers (1515 - 4478)
In VBA, the problem would be trivial as you have already correctly described the logic with the problem statement itself.
Using Excel functionality only, without VBA is the interesting problem. You need to do the following steps to achieve an output that looks like this...
The steps are as follows:
Pivot Table: Make a pivot-table from the Columns (B) and (C) with Rows Fields as (B) and (C) and the minimum of AMOUNT(B) as the Value field. (See Figure below)
Helper Columns: Make a column on the side of the pivot table, say (Q) which is simply equal to everything in column (P)
Contd ... : In column (R) (which unfortunately happens to be in the sheet's column Q, sorry for the confusion there), as shown, for cell Q20 for e.g. put in the formula
=IF(P21=P20,Q21&","&M20,M20)
That will result in the creation of something like the table below:
Table:
(P) (Q)
12 9993
44 1452
47 4478,1515
47 4478
49 4541
99 4444
100 4287,1224
100 4287
Now the hard work is done. All you need to do is to lookup using VLOOKUP key-value pairs from this helper table (P)(Q)
- It will be very fast because the pivot table always keeps it sorted and hence an exact LOOKUP is not necessary.
- Screenshots are shown below for the Pivot table as well as for the final VLOOKUP formula
Pivot Table and Helper Table:
Final Formula:
so I'm using the Countif to see if there are dups based on column A.
In the D column type, =IF(COUNTIF($A$2:$A$9,B2)>0,C2,"")

Add .html to each single field value and add new field with 'custom_permalink'

I have CSV file and I can view it in excel. Here is example data:
ID Product Name
75 dale-earnhardt-jr-adult-costume
77 dale-earnhardt-jr-adult-costume-2
79 plastic-jeweled-crown
81 dollar-ring
83 the-wizard-of-oz-shoe-covers-child
1) I need to add '.html' at the end of product name like dollar-ring.html
2) I want add new column with value 'custom_permalink'
Output should be like:
ID New Column Product Name
75 custom_permalink dale-earnhardt-jr-adult-costume.html
77 custom_permalink dale-earnhardt-jr-adult-costume-2.html
79 custom_permalink plastic-jeweled-crown.html
81 custom_permalink dollar-ring.html
83 custom_permalink the-wizard-of-oz-shoe-covers-child.html
I've 30K records and want to add this using some easy way of excel?
Open/import your CSV file in Excel. Say, it is now in columns A and B.
In cell C1 write =A1.
In cell D1 write custom_permalink.
In cell E1 write =B1&".html".
Select cells C1:E1 and fill the formula till the bottom of your data.
Copy and paste special columns C:E as values only.
Delete columns A:B.
In cell B2 of CSV file add the below formula.
=CONCATENATE(A1, ".html")
Select the range in column B and filldown formulas using shortcut key CTRL+D.

Split comma-separated entries to new rows (No VBA)

I currently have this data in a sheet:
Col A Col B
105 399, 400
207 405,406,407
and want to split the comma-separated entries in the second column and insert them in new rows as below:
Col A Col B
105 399
400
207 405
406
407
without resorting to VBA.
Is this possible?
Split ColB with Text to Columns and Space and Comma as delimiters. Follow the process described here then delete ColumnB, select (Blanks) in Value column and delete those rows. If you do not want the ColA values to repeat, in a new column Row2 insert:
=IF(A1<>A2,A2,"")
and copy down to suit. Select that column, Copy, Paste Special, Values over the top then copy again and paste into the Table. If you don't want Table format, right click within it and Table, Convert to Range.

Resources