Skipping blank cells with an Index/Match formula - excel

I've got several databases containing 100/1,000's of rows where the information is presented something like this:
I need to get all the information relevant to each company onto one row; I'm not able to do a simple Sort & Filter as nearly every company has a different level of detail, so information ends up in the wrong rows. Looks like the best option is an Index/Match formula, but my current formula
=INDEX(Sheet1!B:B,MATCH(Sheet2!$A2,Sheet1!$A:$A,0)
returns zeros for any result where the first Index/Match result is blank:
How can I write the formula so that it skips the blank cells? I'd prefer not to have to use VBA however any advice would be very much appreciated.

Alternatively,
Because match is always the return the first value it found.
So in cell G2,
=INDEX(Sheet1!G:G,MATCH(Sheet2!$A2,Sheet1!$A:$A,0)+COUNTA($G$1:G$1)-1)
Or by matching the header to offset the cells.

You can just wrap your existing formula in an IF function:
=IF(Sheet2!$A2<>"",INDEX(Sheet1!B:B,MATCH(Sheet2!$A2,Sheet1!$A:$A,0),"")

I will normally use a "Go To Special" function for this.
Say for example for the sample data below.
I will put in the first formula '=IF(B2<>"",C3,"")'. Copy that cell (Ctrl+C), then select cells from C2 to C7 and use the 'Go to special' to select Blank cells only under Home tab, in Editing > Find & Select > Go To Special. Simply just Paste the formula to all the blank cells by Ctrl+V. You will get all the information in one row on the first row for each companies.
Hope this helps.

Step1:
Create a pivot table with your data and in the pivot options select 0 for the blank cells.Copy all the fields into row area...
Step2:
Apply conditional formatting as shown in the below image to remove (blank) cells.
Note: This is not a robust solution but worked for me.

Related

Filling every other row with the value of the following row

I'd like to fill every other row in an excel worksheet with the value that is following that row.
See example.
Is there a way to accomplish this?
I am sorry if this is an extremely easy task, but I just can't get my head around how this may work, since just plain copying the data, filtering for blank rows and pasting it into the filtered table just doesn't work as I want it to.
Thanks in advance.
Edit: It might be worth adding that I cannot at all change rows or columns in the excel sheet since it is connected to a database which configuration does not allow this.
Add a new helper column with the formula =ISEVEN(ROW()).
Filter this column on TRUE.
Select the range from A2 to the bottom-right of the cells that you want to populate, and input =A3 [Ctrl-Enter].
Clear the filter and delete the helper column.

Excel vlookup matching on last column and return row

In excel I have a table on sheet 1:
Within sheet 2 I want to do something like a vlookup which looks for 'not done'in the status column and if found then the whole row is shown in sheet 2. Also an added complication is that I would prefer not to have gaps i.e. for any rows showing 'done' as below:
As I state above I have been trying with VLOOKUP and CHOOSE but I cant get anything to work. Can anyone suggest some ideas?
You can use a CSE formula (entered with CTRL+SHIFT+ENTER).
If your data is in A1:C7 (including header row), you can put this in E2 and drag right and down:
=INDEX(A$2:A$7,SMALL(IF($C$2:$C$7="not done",ROW(A$2:A$7)-ROW(A$2)+1),ROWS(A$2:A2)))
Wrap that in IFERROR([formula above],"") to hide #NUM errors when it runs out of results.

Expanding an Excel formula without referencing the previous cell

I am attempting to use an IF statement to check whether the sum of two cells from another Excel sheet is greater than or equal to 1.
For a sheet called Test1 with the values of interest in column C, this is what I have so far, which works fine:
=IF((Test1!C1+Test1!C2>=1),1,0)
In column B on a second sheet that I'll call Test2, I want to copy this formula down 200,000 rows. However, if the aforementioned formula is in cell B1, for the formula in B2 I would like the formula to read:
=IF((Test1!C3+Test1!C4>=1),1,0)
I want to copy the formula down the column so that the second cell reference in the formula in the first row does not become the first cell reference in the formula in the second row (eg. it would go C1+C2, then C3+C4, C5+C6, etc.).
I have tried manually entering the formula for a few rows, highlighting those, and copying them down but can't get the desired cell reference pattern. If I highlight and drag these first three formulae down another three rows, C4 and C5 are repeated and not in the correct pair.
=IF((Test1!C1+Test1!C2>=1),1,0)
=IF((Test1!C3+Test1!C4>=1),1,0)
=IF((Test1!C5+Test1!C6>=1),1,0)
=IF((Test1!C4+Test1!C5>=1),1,0)
=IF((Test1!C6+Test1!C7>=1),1,0)
=IF((Test1!C8+Test1!C9>=1),1,0)
I have tried using OFFSET() within this formula but couldn't get it to work. I am basically just wanting to add 1 to each of the cell references in the formula, as compared to the previous row (but not to actually add 1 to the value of that cell, as would happen with C1+1 for example).
Any insight would be greatly appreciated!
If you plan on copying this down 200K rows then you will want the absolute simplest formula that accomplishes the stagger. Avoid the volatile OFFSET function or be prepared to spend a lot of time waiting for random calculation cycles to complete. A volatile function will recalculate whenever anything in the workbook changes; not just when something changes that involved the formula in the cell.
=--(SUM(INDEX(Test1!C:C, (ROW(1:1)-1)*2+1), INDEX(Test1!C:C, (ROW(1:1)-1)*2+2))>=1)
The following formula should do the trick:
=(SUM(INDIRECT("C"&ROW()*2-1);INDIRECT("C"&ROW()*2))>=1)*1
And that's the version using IF:
=IF(SUM(INDIRECT("C"&ZEILE()*2-1);INDIRECT("C"&ROW()*2))>=1;1;0)
You say I am basically just wanting to add '1' to each of the cell references in the formula but appear to be incrementing by 2, so I am confused but an option might be to apply you existing formula to 400,000 rows, together with =ISODD(ROW()) in another column, then filter on that other column to select and delete those showing FALSE.
Excel's autofill won't do the 2-cell shift that you're looking for. You can use the functionality that is there.
Put =IF((Test1!C1+Test1!C2>=1),1,0) in the top cell and drag a copy to the second row (it will be =IF((Test1!C2+Test1!C3>=1),1,0) but that's okay). Now, put 'A' and 'B' in the next column. Select all 4 cells and copy them down 400k rows.
Use filter to delete rows flagged with 'B' and delete the blank rows.
(Select blank rows with [F5] click Special and select Blanks, then right-click and delete)
Here is all you need. It's fast and nonvolatile.
=--(SUM(INDEX(Test1!C:C,ROW(1:1)*2-2):INDEX(Test1!C:C,ROW(2:2)*2-2))>=1)
Copy it down as far as you like.

Trying to select rows that matched in vlookup excel

I am trying to select the rows of the results from my VLOOKUP and put the results in a neat table in another sheet. The row in my "M" column has a lot of NA and random numbers that were matched.
See this image for clarification:
I want to select all the rows that returned a result and move those rows to another sheet in a table without blank rows between the results. I am not sure how to do this but I know a resident stackoverflow pro probably thinks this is cake. Thanks for the help in advance!
You could make use of a filter:
Select your table and put a filter (under Home tab, Sort & Filter).
Uncheck the #N/A in the selection filter (click the little grey box with black arrow for the column where there are the #N/A that appeared when you inserted the filters).
Copy and paste everything you need into the other sheet.
You can do this with some formulas:
In the column next to your VLOOKUP (I assume it's column C) place a 'counter formula'- in D2, place =IF(ISERROR(C2),0,1), in D3 and below: =IF(ISERROR(C3),D2,D2+1)
Create a new table (say in starting in column F in the same sheet)
In the first column of the table, just place increasing numbers (e.g. in F2: =ROW()-1)
In the next columns, use INDEX/MATCH to retrieve the results, e.g. in G2: =INDEX(A:A,MATCH(F2,D:D,0))
Done!

Highlight Rows in Sheet1 that match values in Sheet2

It's been a long time since I've done anything advanced in Excel. I have Excel 2010. I've watch many videos and tried some tutorials that do sort of what I'm looking for, but I'm just missing something.
This is what I'm trying to accomplish... I have a list of about 50 SKUs in Sheet2. I have a complete list of 200 Products in Sheet1.
SHEET1:
ColA are SKUs
ColB is Desc
ColC is Price
SHEET2:
ColA are SKUs
I need a formula or Macro that will look at all SKUs in Sheet2, then find any matches in Sheet1 ColA, then highlight the rows where there is a match.
I would really appreciate any help you can provide, even if it's just a link to an exact example. Thank you!
If you just want to mark matching rows you can do something easy. This will return matching SKUs, or #N/A if no match:
=VLOOKUP(A2,Sheet2!$A:$A,1,FALSE)
If you really want highlighting you could use the helper formula above and set up conditional formatting (CF) over the range. The CF formula will be something like
=NOT(ISNA($D2)) (assuming you put the VLOOKUPs in column D)
There is another way to do CF that uses no helper formula. First you need to set up a named range on Sheet2 A:A. I'll call it SKUs in this example.
Then a CF formula like this will tag matching rows:
=MATCH($A2,SKUs,0)>0
Edit: I am assuming the data (and CF range if you use that) starts in row 2, allowing for a header in row 1.
This may be a little late, but I figured I would still add my 2 cents. I use the following formula to do something similar...
=IFERROR(IF(VLOOKUP(B1,Sheet2!$A:$A,1,FALSE)>0,"Y","N"),"N")
Basically I just have a column of Y or N for if that item is also on "Sheet2" and this is the formula that decides whether it is a Y or N.
Just use your VLOOKUP() along with IFERROR() in a conditional format formula.
Select the range you would like to apply conditional formatting then do Home -> Conditional Formatting (in 2007) then "Apply a formula".
Then you'll want to apply a formula more or less like this one:
=IF(IFERROR(VLOOKUP($A2, Sheet2!$D$2:$D$4, 1, 0)), 0, 1)
Just adapt the ranges to your needs. I tested this to work on 2007.
You can use conditional formatting in Excel 2010 to achieve what you want to do.
There are 2 ways to do this. The first one works only with the ranges in one sheet whereas the second one lets you work across sheets.
Assuming you can copy and paste both the ranges in one worksheet, you can select both ranges using Control key. After selecting the ranges, Go to Home->Conditional Formatting->Highlight Cell Rules->Duplicate Values. Now Select Duplicate in the dialog box and it should highlight the names in Range 1 that are appearing in Range 2 (your original SKU list).
If you can't copy and paste the second range into the same worksheet, then you have to use a formula with conditional formatting. Select the used range in ColA in sheet1, Go to Home->Conditional Formatting->New Rule. Now Select the Rule Type 'Use a formula to determine which cells to format'. Now type the formula like this (this formula assumes that your cursor is in A1 when you apply invoke the dialog)
=COUNTIF(Sheet2!$A$1:$A$3,Sheet1!A1)
That should highlight in Sheet1 all the items found in Sheet2. Edit the above formula to include the correct range for your situation and use a dynamic range if you know how to do it.
I have used approach 1 countless times and I have just tested approach 2 with a sample and it works. If they don't work for you, please let me know and I can help you further.

Resources