Is it possible to Vlookup a value and copy the entire row that matches
For eg: if I am searching for id=1234 in sheet A
1234 ABC DEF HIJ
The Vlookup should return the entire values.
I am trying to apply this formula in alternate rows of a sheet-The look up value is always in Column A (in the row just above).
Is this possible?
I am a novice in Excel VBA and any help is much appreciated.
Thanks
You would need a separate VLookup for each piece of data
=Vlookup($A1,Sheet1!$A:$C,Column(Sheet1!B:B),false)
If you use this code in the first cell and copy it across it will give you the correct formula for each piece of data.
I have assumed that the data you are searching for is in cell A1 of the current sheet and that the data you are searching is in Sheet1 between Columns A and C. You will need to modify these values if you are doing something different.
To get the position of an item use the Match Function instead of Vlookup.
position = WorksheetFunction.Match("1234", Worksheets("yoursheet").Columns(1), 0)
Now you can use the position to copy the entire row like
Worksheets("yoursheet").Rows(position).Copy
Related
I have a table in Excel with multiple rows. for example in cell A2 I have formula (=B3). The problem is if I sort the table. After sorting the row 3 moves to different row (example 5) but the formula remains the same = (=B3).
Is there a way so that even if I sort the table the formula gets the value from the proper cell in row?
this maybe simple but could not figure out. hope you can help.
You can prefix the sheet name. For example instead of "=B3" use "=Sheet1!B3", then the formula will not change after sorting.
I have data in two separate excel sheet in single file.
In the first sheet, I have two columns...like this
Sheet1
In the second sheet, I have one of the column which is same as Name in Sheet1. However, it does not have second column where I want to bring the value referring to the sheet 1.
Here is the second sheet.
Here in second column, i.e. Color I want to bring the value from first sheet.
I am using Libreoffice but can use excel as well. Pls suggest how I would do this in excel / libreoffice.
Solution for Excel...
So use sheet one as the reference sheet. Sheet two as the one you want to fill.
In B2 on Sheet 2 enter this formula:
=vlookup(A2,Sheet1!$A$1:B$6$,2,FAlSE)
Then drag down.
This is assuming that your reference in sheet one is in columns A and B and goes from rows 1 to 6.
Hope this helps.
One of the easier ways to do this would be to use VLOOKUP. So this requires 4 inputs:
The value you are searching for
The array you are searching in
The column where the value you want to return is in
"FALSE" to list if you want an exact match between the value you are searching for and the array you are searching in.
So in your example, we will use the worksheet where you only have the Names listed as the worksheet you are putting the formula, so something like this in B2:
=VLOOKUP(A2,sheet2!$A$2:$B$6,2,FALSE)
So this would lookup the value you show in worksheet 1 cell A2.
Then go to workbook 2 and match that value with what is in A2:A6.
Then lookup what is in column 2 for your answer.
And return what is in column 2 only if worksheet 1 cell A2 and something in worksheet 2 range A2:A6 is an exact match.
There are other ways, but for your example, this should be easiest in EXCEL. This only works if the value you are searching for is to the right of the value you are looking up. If you need to go to the left, INDEX/MATCH would be better (but not required here).
Hope this helps!
JW
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.
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.
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