Excel/VBA check if a whole row is present on another sheet - excel

A quick question. I am trying to detect if a row is present on another sheet. Simply said, if article+description+quantity+serial is present on another sheet, output a "Y" otherwise, output a "N". The problem I am facing with this, is the fact that the rows on the other sheet could be anywhere, there isn't a fixed position, only the column is known.
However, both the sheet on which the Y/N calculation has to be made, as the sheet on which the row should be searched/found, are dynamically generated by the means of VBA.
Example of the tablestructure
Looking at the =COUNTIFS, I am actually wanting to have =COUNTIFS(A1;="Sheet2!A1:D100"), but the COUNTIFS functionality doesn't support the "range" lookup. I just want to search "ROW(1) in Sheet2!A1:D100"...
Does anyone know in which direction I should be looking?

You could use a Helper column which combines Number, Description & Serial.
Formula for Helper column:
=$I3&"_"&$J3&"_"&$L3
Formula for Instock column:
=IF(COUNTIF($M$3:$M$6,$E3)>0,IF(SUMIF($M$3:$M$6,$E3,$K$3:$K$6)>=$C3,"Y","N"),"N")
Instock formula checks if the value in the Helper column of Sheet1 appears in Helper column of sheet2. If appears, it is also check the sum of available parts satisfy the amount needed.
Output:

Related

Incrementing a column number within formula

Here is my formula:
{=MAX(ROW($1:$120)*(Table1[results1518]=1))}
so far I have done 1518 cells manually as indicated by the results#.
I have about 2000 more cells to go. The table is on one sheet and this formula in each cell on another.
I need to find a way to increment the results# from one cell down to the next cell below it and so on down the column on the second sheet.
I would make a helper column that listed all the result# you needed to cycle through. You can either use excel's auto fill ability or just add 1 to the value of cell in the row above. For example, A3=A2+1.
Next create a second helper column that returned a text value embeding that number. B2 would look something like this ="Table1[results"&A2&"]"
Finally, you can use Excel's indriect formula looks up the value specified by the second helper column. {=MAX(ROW($1:$120)*(INDIRECT(B2)=1))}
There are probabally more effecient methoods, but without knowing more about your setup, this is what I've got.

Comparing and filling in excel data

I have two excel spreadsheets. The first column of each is a column of serial numbers. Basically I need to take the first sheet, match the serial numbers from the other sheet (they are out of order and some are missing) and the fill in the unique data from the fist sheet into the appropriate columns of the second sheet. Does that make sense? I'm an excel noob, but I'm trying to learn! Thanks!
You could use VLOOKUP in order to do that. In cell B2 on your second sheet, use the formula
=VLOOKUP($A2,Sheet1!A:B,2,FALSE)
From this, just add the column range as the second input between the serial number and the column you want to look up. Then repeat for each column.
This picture shows the setup in the first sheet:
All of the data is hard coded.
This picture shows the setup in the second sheet.
As #timthebomb suggests, the formula in the second column (second row) is the following Vlookup:
=VLOOKUP(A2,Sheet1!$A$2:$B$9,2,FALSE)

How can I search across Excel sheets?

I want to transfer data automatically from 2 sheets to one single combining one. That means I have 2 different export sheets (called 'Te_open' and 'Te_closed') that contain both the columns "Problem" (in different positions, can vary always). I have one sheet, that represents an overview of the data from the two other export sheets. So when I have for example the value "Te1" in the cell A2 of my overview sheet, I want Excel to search in the two export sheets the value "Te1" and give back the value in the same row as "Te1" but of the column "Problem", so that I can fill the cell B2 where I want to have the Problem type. So I thought I might need the "MATCH" formula, to let excel know I want to search the column with the headline "Problem" in the export sheets, to fill the column "Problem" in my overview sheet.
The problem that I see is that I have to search TWO sheets and I don't know in which one the "Pm1" will appear. Furthermore I don't know in which column of the sheet "Problem" will appear.
Can you please help me? I would preferably like to solve the problem with a formula, not a macro. Thank you very much in advance.
Kind regards,
question
To find the index of the first column in one of your sheets that is headed 'Problem', you can use (e.g.):
=MATCH("Problem",Te_open!$1:$1,0)
Let's assume we place that formula in a cell somewhere and name the cell open_col. To find a value in column A of Te_open and return the corresponding value from the 'Problem' column, you can then use:
=VLOOKUP(A2,Te_open!$A$2:$Z$999,open_col)
Note that you'll have to define the search range to include the largest range that your data on Te_open could occupy. If the search value is found this will return the corresponding value from the 'Problem' column, otherwise it'll return #N/A. So if you've also set up a cell called closed_col to get the column index for the Te_closed sheet, you can do:
=IF(ISNA(VLOOKUP(A2,Te_open!$A$2:$Z$999,open_col)),VLOOKUP(A2,Te_closed!$A$2:$Z$999,closed_col),VLOOKUP(A2,Te_open!$A$2:$Z$999,open_col)
That gets the result from the correct column of Te_open if the search value was found there, otherwise it gets the result from the correct column of Te_closed. If neither sheet contains the search value it'll return #N/A.

Excel contains filter with more than 2 values

Does anyone know how I can quickly hide/remove all rows in sheet1 that contain any of the rows info from sheet2?
It would need to contains filter as it wouldn't be an exact match.
For example
Sheet1:
http://www.google.com/something/else
http://www.yahoo.com/whatever
www.microsoft.com/hahha
Sheet2:
google.com
So the end result would be the first line in Sheet1 would be hidden
In practice I'm working with thousands of rows in sheet1 and around in Sheet2.
To clarify, I'm essentially trying to do a contains filter with more than 2 values - the default filter only allows 2 values.
Also I am working with Excel for Mac 2011.
You can do this quickly with a simple helper column without a large range loop.
For simplicity as a sample:
Assuming your Sheet 1 list was in A1:A1000
your Sheet 2 partial list was in C1:C5 (on the same sheet for the picture below)
then in range B1:B1000 enter this array formula,
=MAX(IF(ISERROR(FIND($C$1:$C$5,A1)),0,1))=1
(Enter as an array formula by pressing Ctrl+Shift+Enter)
Then AutoFilter the TRUErows (which flag any matches) and hide them
As i was reading the solution posted by #brettdj I think it should work for your problem.
From your comment it seems you have an empty cell problem when using his solution. Are you sure you replaced the $C$1 : $c$5 with the right values?
In your case you should first refer to the right sheet (Sheet2 if you didn't rename it) then the right column (assuming you have it in column A of sheet2).
You should write =MAX(IF(ISERROR(FIND(sheet2!$A$1:$A$5,sheet1!A1)),0,1))=1.

VLOOKUP & Inserting Text That Corresponds To The Cell

I'm having difficulty getting my vlookup formula to pull url data from another sheet (Sheet 2) and insert added information to the url based on what is in its A cell on Sheet 1.
For example,
The vlookup formula =VLOOKUP(B2,Sheet2!A:B,2,FALSE) will check to see if B2 (Sheet 1) matches with Data on Sheet 2. It will then return the data it has matched:
=HYPERLINK("http://www.dpd.co.uk/tracking/quicktrack.do?search.consignmentNumber="&Sheet1!A2&"&search.searchType=16&search.javascriptValidated=0&appmode=guest")
I then want the url link to insert whatever text is in the Sheet 1 A cell.
The formula I have used does this nicely, but I want the formula to correspond down the workbook for whatever is in cell A, not just A1 i.e. Sheet 1 A3,Sheet 1 A4....
How can I do this?
Thanks
I'm not sure if I completely understand what you are asking but allow me to share my experience with what I believe was a similar problem.
My solution was an offset/match formula. I used a formula similar to:
=OFFSET($A$1,(MATCH(B$2,'Sheet2'!$A:$B,0)+$A1),0)
And had a list of values in column A that corresponded to the distance that row was to the object cell I wanted to keep constant. Then I used autofill to fill column a down the sheet as far as I filled the formula. This way offset refrence changed on each row and I was still able to auto fill.
I hope that helps

Resources