0

我有一个可以更新的工作表。用户输入一个表号进行实时更新,然后宏将查看Column 9 (I)并复制B:D该行并将其粘贴到前表(封面)的单元格中。这将一直持续到数据表中的所有数据都用完为止。

Sub Update_Current()
    Dim Page
    Dim lastrow As Long, i As Long
    Dim ws As Worksheet

    lastrow = ActiveSheet.Range("D1000").End(xlUp).Row + 1

    Page = InputBox("Which week would you like to update?")

    If Page = 1 Then
        Worksheets("Week(1)").Select

        For i = 6 To 100
            If ws.Cells(i, 9) = "2" Or ws.Cells(i, 9) = "3" Then
                Range("i,2:1,4").Copy

                {TORN ON WHAT GOES HERE}

            End If
        Next i
    End If
End Sub
4

1 回答 1

0

我知道已经很晚了,但是当我认为我有一个问题时,我不能没有答案就留下一个问题。希望这会对其他人有所帮助。

Sub Update_Current()
Dim Page
Dim lastrow As Long, i As Long
Dim ws As Worksheet

Page = InputBox("Which week would you like to update?")

If Page = 1 Then
   Set ws = Worksheets("Week(1)")
   ws.Select
    For i = 2 To 100
        If ws.Cells(i, 9) = "2" Or ws.Cells(i, 9) = "3" Then
            ws.Range("B" & i & ":D" & i).Copy
            ThisWorkbook.Sheets("CoverPage").Select
            lastrow = ThisWorkbook.Sheets("CoverPage").Range("D1000").End(xlUp).Row + 1
            ThisWorkbook.Sheets("CoverPage").Range("B" & lastrow).PasteSpecial xlPasteValues
        End If
    Next i
End If
End Sub
于 2013-08-29T06:17:07.803 回答