View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
billbeecham[_10_] billbeecham[_10_] is offline
external usenet poster
 
Posts: 1
Default if cell value matches then copy another cell


Hey there,

I was able to get some help before with a problem that consisted of
checking two excel files for cell matches and placing either a "Exists"
or "Does Not Exist" in a cell depending on if the cell value in one
excel file exists in another. This was done to help sort out what
products existed in the one file but not the other.

That has been working great!!!

Now I have a new problem and I have tried to do it myself but not being
to familiar with excel macros I am having a hard time.

I still want the macro below to do what it does, but is there a way to
put the standard "Exists" and "Does not exist" as well as copy cell C
from the new to the old as well?

I have two sheets that have mostly the same data, though not in the
same order. The old sheet has descriptions that have been cut off, the
new has the full descriptions. I need to compare cell A of new to cell
A of old and if they match it writes "Exists" and then copies cell C
from the new to cell C from the old. Get it?

I just want to make sure the full descriptions are copied over the
incomplete ones. Would be easy if all the data was in same order, but
it isn't. When I tried to do it it just copied straight down the
list... which doesn't match.

Here is the macro that was first given to me to figure out which items
in the new existed in the old, and vice versa.

Sub CheckExistenceCopy()
Dim NewRange As Range
Set NewRange = Range("'walloffame-u864xprt.xls'!A:A")

Dim OldRange As Range
Set OldRange = Range("'toystore-112105.XLS'!A:A")

Dim NrIndex As Long
Dim OrIndex As Long

Dim SearchedFor As Range

For NrIndex = 1 To NewRange.Rows.Count
If NewRange.Item(NrIndex).Value < "" Then
Set SearchedFor = OldRange.Find(NewRange.Item(NrIndex),
LookIn:=xlValues)

If Not SearchedFor Is Nothing Then
Range("'walloffame-u864xprt.xls'!B" & NrIndex).Value = "Exists"
Else
Range("'walloffame-u864xprt.xls'!B" & NrIndex).Value = "Does Not
Exist"
End If
End If
Next NrIndex
End Sub

I see where the match occurs and does not. I just can't figure out how
to tell it that when it matches insert the value "Exists" AND copy cell
C from new to old sheet.

I'm sure it is something pretty simple. It always seems to be
simplicity that gets me. Kinda like not being able to see the forrest
for the trees.


I am attaching new and old sheets so you can see what I mean.

I hope I have explained this well. I need to copy the description from
new to old as well as do the "exist" and "does not exist"

The only difference is the attached are .txt and in the macro they are
..xls (Because I can only attach a .txt)

Thanks,

Bill


+-------------------------------------------------------------------+
|Filename: walloffame-u864xprt.txt |
|Download: http://www.excelforum.com/attachment.php?postid=4073 |
+-------------------------------------------------------------------+

--
billbeecham
------------------------------------------------------------------------
billbeecham's Profile: http://www.excelforum.com/member.php...o&userid=16286
View this thread: http://www.excelforum.com/showthread...hreadid=488417