如何将单元格复制到最后一行并粘贴到另一张纸上? [英] How to copy cells to last row and paste to another sheet?

查看:146
本文介绍了如何将单元格复制到最后一行并粘贴到另一张纸上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ActiveSheet脚本,在该脚本中,我将原始数据移至Q:V行.我有一个运行的VBA脚本,并显示了最后一行的位置,在这种情况下,最后一行是77.

I have an ActiveSheet script, in where I take raw data move the data to rows Q:V. I have a VBA script that runs and shows where the last row is, in this case the last row is 77.

lastrow = .Cells(.Rows.Count, "Q").End(xlUp).Row

我想把它从Q到V的最后一行放到哪里,将其复制并粘贴到工作表1中...

I want to have it where it takes from Q to V last row, copy, and paste it into sheet 1...

我猜它看起来会像这样,但是我想先在这里验证...因为我去的常规站点由于某种原因而停机.

I am guessing it will look like this, but I want to verify here first... since my normal sites I go to are down for maintenance for some reason.

Sub test()
         Dim wsPOD As Worksheet
    Dim wsPOT As Worksheet
    Dim wsPOA As Worksheet
    Dim cel As Range
    Dim lastrow As Long, i As Long, Er As Long

    Set wsPOD = Sheets("PO Data")
    Set wsPOT = Sheets("PO Tracking")
    Set wsPOA = Sheets("PO Archive")

        With ActiveSheet
            .AutoFilterMode = False
            Intersect(.UsedRange, .Columns("A")).Cut .Range("Q1")
            Intersect(.UsedRange, .Columns("D")).Cut .Range("R1")
            Intersect(.UsedRange, .Columns("C")).Cut .Range("S1")
            Intersect(.UsedRange, .Columns("B")).Cut .Range("T1")
            Intersect(.UsedRange, .Columns("G")).Cut .Range("U1")
            Intersect(.UsedRange, .Columns("F")).Cut .Range("V1")
            lastrow = .Cells(.Rows.Count, "N").End(xlUp).Row
            Intersect (.UsedRange.Range("Q:V" & lastrow).Copy)
            Intersect (wsPOT.Range("B3:H" & lastrow).PasteSpecialxlPasteFormats)
         End With
End Sub

如果有人可以帮助我,这显然是行不通的,不胜感激.

This obviously doesn't work, if someone can help me it be appreciated.

推荐答案

这就是您要尝试的内容>

Is this what you are trying>

 With ActiveSheet
    .AutoFilterMode = False
    '
    '~~> Rest of the code
    '
    lastRow = .Range("N" & Rows.Count).End(xlUp).Row
    .Range("Q1:V" & lastRow).Copy
    wsPOT.Range("B3").PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
 End With

xlPasteFormats将仅粘贴格式,而不粘贴值.如果要粘贴值,则将xlPasteFormats更改为xlPasteValues

xlPasteFormats will only paste the formats and not the value. If you want to paste value then change xlPasteFormats to xlPasteValues

这篇关于如何将单元格复制到最后一行并粘贴到另一张纸上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆