View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Add new vaue to a different sheet

Sub AdNwExp()
Dim counter As Integer
Dim myRng, cel, exp As Range

Set myRng = Sheet2.Range("B2:B" &
Sheet2.Cells(Rows.Count,"B").End(xlUp).Row)

For Each cell In Sheet1.Range("B2:B" &
Sheet1.Cells(Rows.Count,"B").End(xlUp).Row)
On Error Resume Next
iRow = Application.Match(cell.Value, myRng,0)
On Error Goto 0
If iRow = 0 Then
Sheet2.Cells(myRng(myRng.Count).Row + 1, "B").Value = cell.Value
Set myRng = myRng.Resize(myRng.Rows.Count + 1)
End If
Next cell

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"helmekki" wrote in
message ...

Hi there

'* The code confirms that each value in sheet1 exist in sheet2.
'* I need if the code finds a new value in sheet1 to put it in sheet2
last value..............
This code is my try, but cannot perform the job needed


Code:
--------------------

Sub AdNwExp()
Dim counter As Integer
Dim myRng, cel, exp As Range

counter = 1
Do
Set exp = Sheet1.Range("B2:B50")
Set myRng = Sheet2.Range("B2:B50").Cells(counter, 1)

For Each cel In exp
If cel = myRng Then GoTo 1
Next cel
1:
counter = counter + 1
Loop Until IsEmpty(exp)

End Sub

--------------------


--
helmekki


------------------------------------------------------------------------
helmekki's Profile:

http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=384097