Compare two columns then add another if the data is the same - vba

I have two separate worksheets that I would like to search in and then populate a column if two columns represent the same data. I'm having a hard time explaining this so please have patience.
I have worksheet1 with column "A" having text and numbers in it. In the same sheet column "B" has the data that I want to show in worksheet2 if Both Column "A" match in both worksheets.
Example:
Worksheet1
Column A
Text text text (2012-R-0000)
blah blah blah
text text text (2012-R-0001)
Column B
20-204
20-405
40-609
Worksheet2
Column A
2012-R-0000
2012-R-0001
Column E
(empty) I would like the data in Worksheet1 Column B to be placed here.
Thank you in advance for any assistance with my question.

Assuming your worksheet 1 and worksheet 2 datas starts with A1
use the below formula at worksheet 2 in E1
=VLOOKUP("*"&A1&"*",Sheet3!A:B,2,FALSE)
French Formula:
=RECHERCHEV("*"&A1&"*";Sheet3!A:B;2;FALSE)
and drag down
Proof of Work

Use VLookUp in Worksheet 2 like this.
In cell E1 of Worksheet 2 write the following:
=VLOOKUP(A1;Worksheet1!$A$1:$B$30;2;FALSE)
Then simply drag the formula down. It will match the first column from both worksheets, then paste the corresponding data from column B in worksheet1 to column E in worksheet 2. You'll have to edit "Worksheet1" to match the name of the acctual worksheet, and the number 30 to match the number of rows in worksheet 1.

Related

Excel - Have a value from column B of a 2 column reference pasted anytime the value from column A is entered on a separate worksheet

In the example I have a 2 column reference where data in column E is correlated to column F. I need the data in Column F to show up anytime data from Column E is entered in a separate worksheet if possible.
To be clear, is it possible to enter data in Column A of Sheet 1 that pulls the correlated data from column B in reference Sheet 2 and enters it into Column B of Sheet 1?
I tried using a simple function in a single sheet but it obviously doesn't do what I need.
You are after VLOOKUP or INDEX MATCH
Sheet1 b1 and fill down rows
=IFERROR(VLOOKUP(A1,Sheet2!E:F,2,FALSE),TEXT(,))
Or
=IFERROR(INDEX(Sheet2!F:F,MATCH(A1,Sheet2!E:E,0)),TEXT(,))
If you set you data up as tables the formulas will autofill down. Rather than use entire columns you can set to the ranges containing data.
Data:

look for Column heading and sum up

I have been working with a excel file with a lot of data, which is arranged in 2 sheets.
I would like to get data from sheet 1 to sheet 2 with reference to the column headings.
For example:
So if I want to find the sum of function 1 person A with criteria 1, the command have to go and find the heading "sum of function 1" in sheet 1 and choose the data that are only under criteria 1 and sum it up in sheet 2 cell D5. (By using column heading reference instead of cell reference).
The table range is A2 : U80.
Thanks.
First you have to format your data as table (select the data -> Menu Insert -> Table). Then you rename your table, for example Table1. Let's say one of the columns you want to sum on the sheet2 is called ColumnName.
On the sheet 2 you write a formula
=SUM(Table1[ColumnName])
The result will be what you are after.
You should try it by SUMIFS(). Syntax will be
=SUMIFS(AgeRange from sheet1,NameRange Sheet1, Name cell Sheet2, PlaceRangeSh1, Place Cell Sh2)
Tell me if requires further help.

excel vba use command if

I have two excel files (file 1 with sheet 1 and file 2 with sheet 2).
Both have inside, in column A all the names (for example in A1: "a", in A2: "b" etc etc), in column B the values of relative lenghts (for example in B1: "2", in B2: "3" etc etc) but the orders of the things in the two sheets are different; so, I would want to say: "if the name in a cell in column A of sheet 1 is the same of the name in a cell in column A of sheet 2, so compare the relative values in column B and write TRUE in column C of one of the sheet (if the values are identical) or FALSE"
for you is possible? could you help me, please?
thanks in advance
If Sheet1 has
a 5
b 6
c 7
d 8
and Sheet2 has
c 3
d 8
a 5
then you can type
=IFERROR(IF(B1=INDIRECT("Sheet2!B"&MATCH(A1,Sheet2!A$1:A$4,0)),"Match Found",""),"")
into cell C1 of Sheet1 and drag the fill handle down and you will get
Match Found
Match Found
in column C of Sheet1. No VBA needed. :)
Note: Since your second sheet is actually in a separate file, you'll want to change Sheet2 to [file2.xlsx]Sheet1 in cell C1.
If you want to avoid INDIRECT function then try the following:
Assuming your Sheet1 of file1 is as follows:
And Sheet2 of another file is like:
Enter the following formula in Cell C1 of `Sheet2' and drag/copy it down as required.
=IFERROR(IF(B1=INDEX([file1.xlsx]Sheet1!$B$1:$B$5,MATCH(A1,[file1.xlsx]Sheet1!$A$1:$A$5,0)),TRUE),FALSE)
I would want to copy the word TRUE, only if I compare the same cell of the two sheets and I find that only a part of the name of that cell is the same ( because in reality in cell there is not only a, b, c but a sentence for example as "Sample 1 SX arrow" and others as "Sample 1 DX arrow") and so I want to put in column C the word TRUE only if not complete name in column A are the same but only part of the sentence ( for ecample only the part "SX arrow"!!!
How can I add this in the loop ?

how to create a column that only gets the matching value from another sheet in EXCEL

i would like to create an extra column in sheet one which displays a character (for example G) after it finds the matching values from sheet 2.below are two screen shots i have taken for all your conveniences.
please note,in sheet 1 i have marked two rows with identical bs_cd 6374 which matches the bs_cd 6374 in sheet 2 also.what i want is to have a character G in sheet 1 under column G.
thanks in advance
Insert into the cell G2 this formula and drag it down:
=IF(VLOOKUP(B2;Sheet2!$A$2:$A$100;1;FALSE)=0;"";"G")
Change $A$2:$A$100 to your range in sheet2

VBA code to copy rows from one excel sheet to another

The original spreadsheet was from column A to E. I just pasted the numbers in column F from another sheet. My new spreadsheet has 1517 rows and goes from columns A-H. The numbers in column F (row 2 to row 420) are also in column C.
I was able to use the MATCH function of Excel to find the exact position of a number in column C i.e In column C, on which row can I find the numbers that are in column F? For instance, the number "12345678910" in cell F2 can be found in cell C1049,on row 1049. I put those position numbers in a column that I called "index".
Now, the goal is to write a vba code to copy those rows at once. I am trying to extract/copy to another sheet the numbers in column F that are also in column C but I only want columns A to E - from the original sheet. Copy each row number that is in the index column but only the columns A-E. To be clear, "12345678910" is also in cell C1049. "Copy row 1049 from column A-E" and do that for each position number in the index column.
I cannot sort the spreadsheet because the columns A-E are linked. A sort would alter the information. Any help would be appreciated.
A sample of my spreadsheet
Sub filterCopy()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Set ws1 = Sheet1
Set ws2 = Sheet2
ws1.Range("A1:F1517").AutoFilter 6, "<>"
ws1.Range("A1:F1517").SpecialCells(xlCellTypeVisible).Copy ws2.Range("A1")
End Sub