Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 将第n1行从第x1行复制到第x2行(第1页),然后在粘贴第n行数据后将第n2行复制到第2页_Vba_Excel - Fatal编程技术网

Vba 将第n1行从第x1行复制到第x2行(第1页),然后在粘贴第n行数据后将第n2行复制到第2页

Vba 将第n1行从第x1行复制到第x2行(第1页),然后在粘贴第n行数据后将第n2行复制到第2页,vba,excel,Vba,Excel,我有一个excel文件,在sheet1中有2000行50列。我需要在同一工作簿中,每隔一行从sheet1到sheet2的第3行复制并粘贴到第900行。然后每第6行从第901行到第2000行的第1页到第2页,在之前粘贴的行之后。我对VBA很陌生。谁能帮我写下这个宏 尝试: Dim strValue As String Dim strCellNum As String Dim x As String x = 1 For i = 1 To 700 Step 7

我有一个excel文件,在sheet1中有2000行50列。我需要在同一工作簿中,每隔一行从sheet1到sheet2的第3行复制并粘贴到第900行。然后每第6行从第901行到第2000行的第1页到第2页,在之前粘贴的行之后。我对VBA很陌生。谁能帮我写下这个宏

尝试:

    Dim strValue As String
    Dim strCellNum As String
    Dim x As String
    x = 1
    For i = 1 To 700 Step 7
    strCellNum = "A" & i
    strValue = Worksheets("Sheet1").Range(strCellNum).Value
    Debug.Print strValue
    Worksheets("Sheet2").Range("A" & x).Value = strValue
    x = x + 1
    Next

对于r=3到900第2步
对于r=901到2000第6步
对于r=3到899第2步…对于r=901到1999第6步?如何设置行的strig,我知道如果我只需要值,我可以使用这种类型的代码Dim strValue作为String Dim strCellNum作为String Dim x作为String x=1,用于I=1到700第7步strcelnum=“A”&i strValue=Worksheets(“Sheet1”).Range(strCellNum).Value Debug.Print strValue Worksheets(“Sheet2”).Range(“A”&x).Value=strValue x=x+1下一步,但我不知道如何编写用于复制行的宏不要在注释中添加代码-编辑问题以添加它,并使用
{}
按钮格式化它。
Sub CopyNew()
    Dim NextDest As Long
    Dim CurRow As Long

    NextDest = 1

    For CurRow = 3 To 900 Step 2
        Sheets("Sheet1").Rows(CurRow).Copy
        Sheets("Sheet2").Range("A" & NextDest).PasteSpecial
        NextDest = NextDest + 1
    Next CurRow
    For CurRow = 901 To 2000 Step 6
        Sheets("Sheet1").Rows(CurRow).Copy
        Sheets("Sheet2").Range("A" & NextDest).PasteSpecial
        NextDest = NextDest + 1
    Next CurRow

End Sub