mercredi 12 juillet 2017

Find value in different worksheet

I'm trying to write some code that will, for example, select the value in cell A2 in Sheet 2, compare it with the range A:A in Sheet 1, and if it finds the same value, it copies some values from that row in Sheet 1 and pastes them in Sheet 2. Then it looks at cell A3 in Sheet 2 and repeats the process. Then cell A4 in Sheet 2 etc.

I'm lost from here on out. Any ideas?

Sub Last_Week()

Dim Sheet2 As Worksheet
Dim Sheet1 As Worksheet

Set Sheet2 = ActiveSheet
Set Sheet1 = ActiveSheet.Previous

Sheet1.Activate

Dim i As Integer
For i = 1 To 1500
    Columns("A:A").Select
    Set cell = Selection.Find(What:=(ACTIVATE WS AND SELECT THE VALUE IN COLUMN A AND ROW I)

    If cell Is Nothing Then
'do it something

    Else
'do it another thing
    End If

Next i

End Sub

Aucun commentaire:

Enregistrer un commentaire