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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

column to different sheet column

Status
Not open for further replies.

maximas

Programmer
Nov 29, 2002
40
US
Let said I have sheetA and sheetB. sheetA have columns 1,2,3 sheetB have columns 1,2,3,4 I want to check if sheetA column 1,2 is the same as in SheetB column 1,2. If the same put the content from sheetA column3 to sheetB column4. how would you check that. I have a if function to test, but is only for one cell. How would you put in a module.
=IF(C1=SheetA!C1,SheetA!C1,)&IF(C2=SheetA!C2,,)
 
If this is just an occasional thing, put this formula into all rows of "column 4" of SheetB

From your sample code, I infer that "Column 1" is in Column "B", and "Column 2" is in Column "C", etc. if that is in fact the case, paste this function into E1 ("Column 4") of sheetB and copy down:

=IF(AND(B1=SheetA!B1,SheetB!C1=SheetA!C1),SheetA!D1,"")

The desired values will appear. Good enough for viewing or printing.

Or, you can copy and paste special/values if needed.

A macro could do the same thing. It all depends on how often you need to do this.

 
you are comparing single cell values, not multi cell value. What I meant is that if I have three columns 1,2,3 in sheet A and four columns 1,2,3,4 in sheet B. I want to compare the column 1,2 in sheet A with column 1,2 in sheet B and put the columns 3 from sheet A to columns 4 in sheetB.
I can check for single cells, but for multi cells, my if function don't work. what is your input!
=IF(Column1=SheetA!Column1,SheetA!Column1,)&IF(Column2=SheetA!Column2,,)
put in sheetB in column 4.
 
Help me understand.

If sheetA cell A1 equals sheetB cell A1
and sheetA cell A2 equals sheetB cell A2
and so on for 149 rows
but sheetA cell A150 (for example) does not equal sheetB cell A150
then nothing is copied from sheetA to sheetB?

Please be more specific if you can.

Is this a one-time thing? If so, can do manually with formulas.

Is this something that needs to be done on a regular basis? If so, can be done with a macro, but more details are needed before it can be written.
 
Okay here is the detail!
you have sheetA cellA1 with value 4 and cellB1 with value 5
you have sheetB cellA1 with value 4 and cellB1 with value 5
put value in sheetA cellC1 in sheetB cellC1.
This is a one to one relationship, but if in sheetA the user enters new row above the cellA1 and push the cells from cellA1 to cellA2 and cellB1 to B2. the formula will be broken. Therefor I need a loop to go through the entire column in sheetA, find the cell where the value is saves and then match in sheetB!
 
Forgive me for being so dense, I still don't see what you are wanting or needing.

You say start with:
[tt]
Sheet1: Sheet2:
A B C A B C
1 4 5 X 1 4 5 X
2 6 7 Y 2 6 7 Y[/tt]

Then the user makes it look like this:
[tt]
Sheet1: Sheet2:
A B C A B C
1 2 3 M 1 4 5 X
2 4 5 X 2 6 7 Y
3 6 7 Y[/tt]

Now what is supposed to happen?
What "formula" breaks?
What is Sheet2 supposed to look like now?
Is it just that you need to re-work sheet 2 so that each cell in columns A, B and C has a formula that looks like these:
A1: =Sheet1!A1
B1: =Sheet1!B1
C1: =Sheet1!C1
A2: =Sheet2!A2
etc.
 
this is what really happens!
Sheet1: Sheet2:
A B C A B C
1 4 5 X 1 4 5 don't know
2 6 7 Y 2 6 7 don't know

run macro or functions then C contain X and Y
Then the user makes it look like this:

Sheet1: Sheet2:
A B C A B C
1 2 3 M 1 4 5 don't know
2 4 5 X 2 2 3 don't know
3 6 7 Y 3 6 7 don't know

You can see that the code will break, because the C column with the if will not reference the right cell in sheet1.
Don't worry about it. Thanks alot though. I'm going to another approach! not the validation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top