2017-07-12 7 views
0

シート2のセルA2の値を選択し、シート1の範囲A:Aと比較し、同じ値を見つけたらシート1のその行からいくつかの値をコピーし、シート2に貼り付けます。次に、シート2のセルA3を見て、プロセスを繰り返します。次にシート2のセルA4など別のワークシートで値を見つけよう

私はここから外れています。何か案は?

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 

答えて

1

これを試してみてください:

Sub Last_Week() 


Dim Sheet1 As Worksheet 
Set Sheet1 = Worksheets("Sheet1") 

Dim Sheet2 As Worksheet 
Set Sheet2 = Worksheets("Sheet2") 

Dim i As Integer 
For i = 1 To 1500 
    'search cell A & i from Sheet2 in column A in Sheet1 
    Set cell = Sheet1.Columns("A:A").Find(Sheet2.Cells(i, 1).Value, LookIn:=xlValues) 

    If cell Is Nothing Then 
    'do it something 
    Else 
    'do it another thing 
    End If 

Next i 

End Sub 
関連する問題