View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Add new vaue to a different sheet

Hi Helmekki,

Just a typo warning:

Set exp = Sheet1.Range("B2:B52")
Set myRng = Sheet2.Range("B2:B52")


In the above expressions, B52 should read B50, of course!

---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Helmekki,

Try:

Sub AdNwExp()

Dim myRng, cel, exp As Range
Dim destCell As Range

Set exp = Sheet1.Range("B2:B52")
Set myRng = Sheet2.Range("B2:B52")

On Error GoTo XIT

For Each cel In exp.Cells
If IsEmpty(cel) Then Exit For
With Application
.ScreenUpdating = False
If IsError(.Match(cel.Value, myRng, 0)) Then
If .CountA(myRng) = 0 Then
Set destCell = myRng(1)
ElseIf .CountA(myRng) = 1 Then
Set destCell = myRng(2)
Else
Set destCell = myRng(1).End(xlDown). _
Offset(1)
End If
cel.Copy destCell
End If
End With
Next
XIT:
Application.ScreenUpdating = True

End Sub


---
Regards,
Norman