将循环结果从一张纸复制到另一张

时间:2017-08-28 16:14:13

标签: excel vba excel-vba

我试图在2017年 - 2018年巴西甲级联赛的结果列表中找到一个足球队名称,这个名字很好找到,我希望名字旁边的单元格和下一个5复制并粘贴到另一张AFC伯恩茅斯,我得到的是复制AFC Bournemouth b16:f16有人能告诉我我做错了吗

Sub finddataTeamTimeGoals()
Application.ScreenUpdating = False

Dim findhometeam As String
Dim findawayteam As String
Dim finalrow As Integer
Dim i As Integer

Dim totalmatches As Long

Sheets("AFC Bournemouth").Range("a2:ab50").ClearContents

findhometeam = Sheets("2017-2018 Brazil Serie A").Range("i2").Value
finalrow = Sheets("2017-2018 Brazil Serie A").Cells(Rows.Count, 4).End(xlUp).Row
totalmatches = Sheets("2017-2018 Brazil Serie A").Cells(Rows.Count, 4).End(xlUp).Row
finalrow1 = Sheets("2017-2018 Brazil Serie A").Cells(Rows.Count, 31).End(xlUp).Row

For i = 2 To finalrow

    Sheets("2017-2018 Brazil Serie A").Activate
    If Sheets("2017-2018 Brazil Serie A").Cells(i, 1) = findhometeam Then
        Range(Cells(i, 2), Cells(i, 6)).Copy
        Sheets("AFC Bournemouth").Activate
        Range("b12").End(xlUp).Offset(1, 0).PasteSpecial xlPasteFormulasAndNumberFormats
        Sheets("2017-2018 Brazil Serie A").Activate
        End If
Next i

End Sub

0 个答案:

没有答案