View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Joe Fish Joe Fish is offline
external usenet poster
 
Posts: 24
Default if cell value matches then copy another cell

Bill,
Without looking too closely at the files, an easy suggestion is to have
two more procedures in the module that do everything you want done.
Also, you might find your code more easy to read (and consequently get
more people to help you) if you indent procedures and functions (thus
the expression 'nesting'). Take a look at this:

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
ExistsMacro
Else
DoesNotExistMacro
End If
End If
Next NrIndex

End Sub

Sub ExistsMacro ()
Range("'walloffame-u864xprt.xls'!B" & NrIndex).Value = "Exists"
' Copying and pasting you want to do
End Sub

Sub DoesNotExistMacro ()
Range("'walloffame-u864xprt.xls'!B" & NrIndex).Value = "Does Not
Exist"
' Copying and pasting you want to do
End Sub

Have fun,
Joe