简体   繁体   English

将特殊单元格复制到另一张纸上的下一个空行

[英]Copy Special Cells to next empty row on another sheet

I am trying to copy rows with numbers to another worksheet. 我试图将带有数字的行复制到另一个工作表。 I have obtained the SpecialCells code from another forum but have problems pasting the data into another sheet. 我已经从另一个论坛获得了SpecialCells代码,但是在将数据粘贴到另一个工作表时遇到了问题。 Thank you for your help! 谢谢您的帮助!

Here is the code I have: 这是我的代码:

Sub Sample()

Dim ws As Worksheet
Dim rng As Range
Dim ws1 As Worksheet

On Error GoTo Whoa

Set ws = Sheets("3")
Set ws1 = Sheets("Sheet1")

With ws
    Set rng = .Cells.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow

    Copy ws1.Range("A" & lastrow)
End With

Exit Sub
End sub

You could try this: 您可以尝试以下方法:

Sub Sample()
    With Sheets("Sheet1")
        Sheets("3").UsedRange.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow.Copy .Cells(.Rows.Count, 1).End(xlUp).Offset(1)
    End With
End sub

I don;t see anywehre in your code that you defines and set lastrow . 我看不到您定义和设置lastrow代码中的lastrow

Modify your last section to: 将您的最后一部分修改为:

With ws
    Set Rng = .Cells.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow

    lastrow = ws1.Cells(ws1.Rows.Count, "A").End(xlUp).Row + 1 ' <-- get the last row in column A '<-- just in case you are looking for the first empty row in Column A 
    Rng.Copy ws1.Range("A" & lastrow) '<-- you need to add the Rng.Copy
End With

Please try the code below.This will copy data from sheet named "3" to "sheet1". 请尝试下面的代码。这会将数据从名为“ 3”的工作表复制到“ sheet1”。

Sub Sample()

Dim ws As Worksheet
Dim rng As Range
Dim ws1 As Worksheet

Set ws = Sheets("3")
Set ws1 = Sheets("Sheet1")
LastRow = ws1.Cells(ws1.Rows.Count, "A").End(xlUp).Row

Set rng = ws.Cells.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow
rng.Copy
ws1.Activate
Range("A" & LastRow + 1).Select
ActiveSheet.Paste

End Sub

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将行复制到另一张纸的下一个空行 - Copy row to next empty row of another sheet 复制并粘贴到下一个空行中的另一个工作表 - Copy and paste to another sheet in the next empty row 将数据从工作表中的单元格复制到另一个工作表中的下一个可用行 - Copy data from cells in sheet to next available row in another sheet 从一张纸上复制一定范围的单元格,然后插入下一个空行 - Copy a range of cells from one sheet and insert into next empty row 将数据从一张纸复制到下一个空行的另一张纸上 - copy data from one sheet to another on the next empty row 从范围复制并过去到下一个空单元格中的另一个工作表中 - Copy from a range and past in another sheet in the next empty cell in a row 将下一个空白行中的单元格值复制到另一个工作簿vba - Copy cells values in to next empty row to another workbook vba EXCEL VBA-遍历一行中的单元格,如果不为空,则将单元格值复制到另一行,直到下一行不为空 - EXCEL VBA - Loop through cells in a row, if not empty, copy cell value into another row until next row not empty 我想将单元格的范围从一张纸复制到下一张空白行的另一张纸 - I want to copy a range of cells from one sheet to another sheet in the next blank row 复制列直到一张纸的最后一行,然后粘贴到另一张纸的下一个空行 - Copy columns until last row from one sheet and paste to the next empty row of another sheet
相关标签
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM