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


Yeah, me too. Thanks for trying to help.

I just need to take the time to learn more about this.

I have code to compare like I want using column a. I just need to
figure out how to incorporate a range for C so I can do a copy paste. I
have the copy pste code down, but cannot seem to get the result I want.

Maybe if anyone else out there would like to give a try at it?

Here is what I have so far, it compares sheet1 a to sheet 2 a but only
copies straight down. I need it to copy the same C location as the A
location.

Like, if it compared A23 to A23 I need it to copy C23 to C23 (in sheet1
and sheet2 of course)


so here is my awful macro:

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

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

'Dim MidRange As Range
'Set MidRange = Range("'walloffame-u864xprt.xls'!C:C")


Dim NrIndex As Long
Dim OrIndex As Long
'Dim MrIndex As Long

Dim SearchedFor As Range
'Dim SearchedForAgain 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 MidRange.Item(NrIndex).Value < "" Then
'Set SearchedForAgain = MidRange.Find(NewRange.Item(NrIndex),
LookIn:=xlValues)

'If Not SearchedForAgain Is Nothing Then
If Not SearchedFor Is Nothing Then


'Range("'toystore-112105.XLS'!c" & NrIndex).Value =
OldRange.Find(NewRange.Item(NrIndex), LookIn:=xlValues)
Range("'walloffame-u864xprt.xls'!C" & NrIndex).Copy
Destination:=Range("'toystore-112105.XLS'!c" & NrIndex)
'End If
'End If
End If
End If


Next NrIndex

End Sub


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