0
votes

I have 2 excel sheets:

Sheet1: (Value = Prevalue)

Id   Preval Value    
111  1      1
123  2      2
100  3      3

Sheet2:

Id Num Date
111 5
123 6  1/1/18
100 7

I want to perform a logic saying that: Matching the 2 sheets by Id, if Date on sheet2 exists then Value on sheet1 = num on sheet2 else = Prevalue

Id Value
111  1    (same)
123  6    (update since date exists)
100  3    (same)

How would this be done using index or vlookup? Many thanks!

1
The problem is the keeping of the existing, You can have a formula or you can have a set value, not both. If you put in a formula that is live and it will return the value from Sheet2, whether that be a blank cell or a date. If you enter a value it will overwrite the formula. To do what you are asking will require vba.Scott Craner
the existing values were derived from another cell so I can implement that in the formula. I was thinking it could be IF(exist,update,"old formula")TylerNG
@ScottCranerI made the change. Hope that helps!TylerNG

1 Answers

1
votes

Try this formula:

=IF(VLOOKUP(A2,Sheet2!$A$1:$C$4,3,0)="",B2,VLOOKUP(A2,Sheet2!$A$1:$C$4,2,0))