View Single Post
  #6   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 Bill,

To add, Match is an Excel function; it is not a VBA function and you should
therefore look at the Excel help files.

Only a subset of Excel functions are available to VBA. VBA help provides a
list of these functions.

---
Regards,
Norman



"William Benson" wrote in message
...
Norman,

Any idea why I cannot find .Match as a documented method of the
Application object in Microsoft VBA Help? It seems to work perfectly, and
I wanted to learn about its arguments.

Thanks.

"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



"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