Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Match cells

Status
Not open for further replies.

Xsi

Programmer
May 29, 2015
121
SE
Hello people,

I need a code that loops through the sheet also matching sheet "Sheet1" column "A" and "B" cells same row,

example
PsHBAZ4.png


in this case

USA and ARA

find two cells in any columns in sheet "sheet2" as long they are besides each other on same row matching them in sheet two

hU87jK7.png


then msgbox the matching cells in "sheet2"

this is what I come up with so far,

Could someone help me to correct it


 
 http://files.engineering.com/getfile.aspx?folder=fc8d60a6-02cf-418f-a266-b4b6eb4345ec&file=updated_Compare_cells.zip
I'm confused as what you're trying to do. Your description of what you want (which is confusing) and what your macro is attempting to do (which is only performing a calculation in Sheet 2 to find if there's a match of data in Sheet 1 & 2 and if so, in the row multiply the values in Cell G by the value in J and put the result in cell N).

As the data currently in col J are TEXT not VALUES you're probably getting errors as well as since col J are BLANK. If all you want to do is the calculation, why have a macro? You can easily just put the formula in the cells in col N.
 
the thing I trying to make its...


check each row in sheet "sheet1" column A and B
example:
first row sheet "sheet1"

Column A: Column B:
USA ARA

check after USA and ARA in Sheet "sheet2"

when found take value from column G sheet "sheet2" same row in this case "0.09" * sheet1 column J same row in this case "2" set the new value in sheet "sheet1" same row but column N
for all the Language combinations
 
In the spreadsheet provided, the data is only in the following cells:
Sheet 1: Cols A & B from Rows 1 to 1077
Sheet 2: Cols A, B & G from Rows 1 to 79

In the example you indicated in your 2nd post, to find the data from the first row on Sheet 1: USA ARA
the corresponding data in Sheet 2 is in Row 46, and the value in G49 is TEXT of 0.09 (Note: being text may cause problems with calculations). THERE IS NO DATA IN COLUMN J OF SHEET 1. Where are you getting the 2?

If you are wanting to get the value in Sheet 1, cell J1 and get the result in Sheet 1, cell N1, make the following change:
mystringtwo = Sheets("sheet1").range("J" & r).Text
Sheets("Sheet1").range("N" & r).Value = myresult
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top