I've not written any macros for some years so am rusty.
With Excel 2007 I need go through a whole column of data (assume it's column A) and for each cell in that column try to find the value in column C of another worksheet.
Can Vlookup do this or would I need to use another function?
A basic example using a second sheet reference (Sheet2), with a range in column A:
=VLOOKUP(Sheet2!C2,A2:B5,2,FALSE)
Below is a working screenshot example:
Useful Reference
VLOOKUP function
Related
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
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
I am trying to figure out how to reference a worksheet name in my SUMPRODUCT cell and I can't figure it out. I am not sure if its because my logic is flawed and there is a better way or if what I want to do isn't possible without using VB code.
Basically I have a workbook that has various data. However for this instance I am only looking at a single column, in this case, the DATE. So I am basically using a SUMPRODUCT Formula to read the entire column for a date that is older than 120 days, but not counting items in the column that are blank. So just cells with a date in it.
This workbook will have worksheets added every month and the previous month will be stored. To make this workbook Dynamic, the first work sheet has various graphs to display information and so it can be printed nicely while the last page has all the formulas.
Basically I looking to create a drop down box on the first worksheet. That dropdown list will have the previous months (the worksheets are named by months), and ideally they will be referenced into the formula as it changes.
For example:
My current formula works: SUMPRODUCT(('OCT 2015'!$G:$G<TODAY()-120)*('OCT 2015'!$G:$G<>""'))
I would like the formula to like: SUMPRODUCT(('CELL_THAT_HAS_SHEETNAME'!$G:$G<TODAY()-120)*('CELL_THAT_HAS_SHEETNAME'!$G:$G<>""'))
And that cell it will reference is a dropdown list and corresponds to the sheetname.
You would incorporate the INDIRECT Function:
=SUMPRODUCT((INDIRECT(A1&"!$G:$G")<TODAY()-120)*(INDIRECT(A1&"!$G:$G")<>""'))
I have a formula in excel that looks like such: =COUNTIF(Imports!$B$2:$B$999,"1")
It works like I want it to but part of my manipulation of the spreadsheet requires me to insert new columns in the sheet that formula is referencing. When I do that it changes the formula from column B to column C which is actually not what I want. I want it to reference column B no matter what. How would I achieve this in Excel? Thank you!
Use INDIRECT to reference range from its text address:
=COUNTIF(INDIRECT("Imports!$B$2:$B$999"),"1")
I have a sheet 'MODELS' with columns of data, each column varies in how many cells (rows). I'm wanting to paste a column from this sheet into another sheet 'COMBINED' into a single cell.
For my first cell in COMBINED, I tried using formula:
='MODELS'.A1:A15
However, this resulted in only displaying the data in cell (MODELS) A1 instead of the entire range (A1:A15).
Is there a formula to accomplish this?
I don't think Excel/OpenOffice has a built-in function to do this. You could write a user-defined function (UDF) or a Macro using VBA to accomplish this. Here's a thread which you might find useful:
http://www.mrexcel.com/forum/excel-questions/16401-concatenate-range-cells.html