Comparing excel rows across multiple tables and copying - excel

I've worked on this for about a week and I'm stuck. I didn't see any forms with my problem on here, so hopefully y'all can help.
I'm trying to compare data from sheet2 to sheet1 and if the value in column B is the same, paste the data from sheet2 in the next blank cell in sheet1
I've included a spreadsheet that hopefully illustrates my point better.

=if(sheet2!B(some_number)=sheet1!B(some_number),fill_in_answer_you_want,0)
You would have to input this statement into the cell that you want. For example, in Cell C2 you would write:
=if(sheet2!$B2 = $B2,sheet2!$B2,0)
As for a way to fill in the next blank cell, you would have to write a vba script to find the cell you would like to place it in and place the above formula into the cell.

Related

If a cell in column A in sheet 2 equal to a value from sheet 1 then return the values from sheet 2 to column B and c in sheet 1

I am looking to do a kind of automatic cell updates on excel, which is a status update for a product we got and the location of the product in the warehouse.
I have basic knowledge of VBA and I didn't manage to code anything to help me with that. I tried to use If function, but didn't make sense because I can't find a way to achieve what I need.
Here is sheet 1
and sheet 2
examples.
This is what I am trying to achieve:
if a cell within Sheet2 column A range = Cell A2 in sheet 1, then fill Sheet1, B2 cell and Sheet1, C2 cell with the information from sheet2 on the condition that it is the most recent entry (in the example images it is the entry with the dispatched status)
Would you recommend VBA or using formulas, and if so what should I do?
This can be done with formulas, however getting the latest value isn't as easy as it seems. This can be achieved however by following this tutorial for reference. I especially refer to the part using LOOKUP(.
Other than that, all you need to do is set your ranges to refer to the correct sheet.
=IFNA(LOOKUP(2,1/(Sheet2!A:A=Sheet1!A2),Sheet2!B:B),"")
My formula in B2 is:
=INDEX(Sheet2!$B:$B;MAX(SI(Sheet2!$A:$A=Sheet1!A2;ROW(Sheet2!$A:$A)-MIN(ROW(Sheet2!$A:$A))+1)))
My formula in C2 IS:
=INDEX(Sheet2!$C:$C;MAX(SI(Sheet2!$A:$A=Sheet1!A2;ROW(Sheet2!$A:$A)-MIN(ROW(Sheet2!$A:$A))+1)))
Both formulas are array formulas so instead of entering them with ENTER, they must be entered pressing
ENTER+CTRL+SHIFT at same time
Anyways, these formulas will probably make your file heavy and slower. Think about redesigning the way you save data, and consider adding a date field, and resuming data with Pivot Tables.

Leave referencing cell blank if referenced cell is blank but has a formula

I've searched through so many forums on here to find exactly what I'm looking for but haven't found what I needed.
Basically I have a workbook with cells that reference another workbook. Column A cells fill the date from the other workbook as does column B. I'd like for cells in column C to have an "X" if the cell in column A has actual data in it and left blank if it does not. The problem I'm running into is that Excel is putting an "X" in all of the cells in column C because it's reading that Cell A has a formula in it to pull the data from the other workbook.
Current formula: =IF(OR(ISBLANK(A5>"")),"","X")
I've tried isblank, not, etc, nothing seems to be working. Below is an example of what it's doing:
The problem
What I want
The OR() function typically works with more than one condition. You want to see if either A or B is blank, but you only test for A.
IsBlank() returns true if a cell is blank. You only need to pass it a cell, nothing else. You are using a cell compared to a blank string as the argument, which is not correct syntax.
Try this:
=IF(OR(A5="",B5=""),"","X")
On the other hand, pre-filling a column with a formula is not good data architecture. You can turn the data into an Excel Table object with Insert > Table and enter the formula for the existing rows of the table. Then the formula will automatically be applied to new rows that are added or inserted.

reference same cell from multiple sheets

I am trying desperately to use the INDIRECT function to pull the values from the same cell on multiple worksheets but all I keep getting is #REF. I have all the sheet names in column I. I tried =INDIRECT(I2&"A1") with I2 being the cell with the sheet name and A1 being the cell on that sheet I want to pull the data for. I'm not sure what's going wrong....
You need an exlamation mark.
Try =INDIRECT(I2&"!"&"A1")
It works for me.

Prevent #ref when cell deleted

I'm importing a text file into one sheet, eliminating un-needed lines, while formatting the data on the second sheet.
I have all the formulas on the second sheet set up, referencing cells on the first sheet.
The problem is that after deleting the un-needed lines and the data moves up, the formulas for the deleted lines say #ref. I want the formulas to use, say Sheet1!B2 no matter what data is there.
I see that Indirect works, so the next question is, how can I copy the Indirect function down a colum of 500 rows with each one having the right reference?
Thanks
I had this same problem recently so just passing along the answer I got. Index functions will help. Below you can see one where the sheet name is reference in cell a1 and it will return the value in cell a2 of the corresponding sheet.
=INDEX(INDIRECT($A1&"!2:2"),COLUMN(A:A))
If you only need to reference cells on the same row, including cells on different sheets on the same row, there's an easier way than Indirect.
If you write in A42:
=#B:B
it will look up B42.
If you write in A42:
='Sheet 2'!#X:X
It will look up X42 on Sheet 2.
If you delete the top rows on Sheet 2, the formula on Sheet 1 will point to the new X42 - no #REF! errors.
As long as your formulas in Sheet 1 just need to reference cells on the same row in Sheet 2 - so the formula in 'Sheet 1'!A42 might want 'Sheet 2'!X42 but not 'Sheet 2'!X43 - you can just put the column names as inputs into the formula. Otherwise you'll need Indirect.
For bonus points, name the columns in Sheet 2, so instead of ='Sheet 2'!#X:X you could write =cust_DateOfBirth for example.

VLOOKUP & Inserting Text That Corresponds To The Cell

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

Resources