如果满足条件,则从一行复制一定范围代码已完成,但我找不到正确的 vba 语法

问题描述

所以我有 7 列,第 5 (E) 列是日期。我正在搜索日期的所有行,并根据我的输入将它们复制到工作表 2(从 1 开始)。问题是我只需要复制 A、B、C、D、E,但省略最后 2 列。正确的语法是什么?

我有自动取款机:

Rows(i).copy Destination:=Sheets(2).Rows(Lastrowa)

但这会复制我的整行,而不仅仅是该行的前 5 个单元格。完整代码如下

Sub Check_Dtaes()
'And Format
Application.ScreenUpdating = False
On Error GoTo M
Dim i As Long
Dim ans As Date
Dim anss As Date
Dim Lastrow As Long
Dim Lastrowa As Long
ans = InputBox("Start Date Is")
anss = InputBox("End  Date Is")
Lastrow = Sheets(1).Cells(Rows.Count,"E").End(xlUp).Row
Lastrowa = Sheets(2).Cells(Rows.Count,"E").End(xlUp).Row + 1
    For i = 1 To Lastrow
        If Cells(i,"E").Value >= ans And Cells(i,"E").Value <= anss Then
            Rows(i).copy Destination:=Sheets(2).Rows(Lastrowa)
            Lastrowa = Lastrowa + 1
        End If
    Next
    
    Sheets(2).Range("E1:E" & Lastrowa).NumberFormat = "dd/mm/yyyy"
Application.ScreenUpdating = True
Exit Sub
M:
MsgBox "You entered a inproper date"
Application.ScreenUpdating = True
End Sub

提前致谢

解决方法

Range("A" & i & ":E" & i) // 感谢 BigBen,谢谢