简体   繁体   English

如何将单元格复制到最后一行并粘贴到另一张表格?

[英]How to copy cells to last row and paste to another sheet?

I have an ActiveSheet script, in where I take raw data move the data to rows Q:V. 我有一个ActiveSheet脚本,我在其中获取原始数据将数据移动到行Q:V。 I have a VBA script that runs and shows where the last row is, in this case the last row is 77. 我有一个运行的VBA脚本,并显示最后一行的位置,在这种情况下,最后一行是77。

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

I want to have it where it takes from Q to V last row, copy, and paste it into sheet 1... 我想把它从Q到V的最后一行,复制并粘贴到表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 will only paste the formats and not the value. xlPasteFormats只会粘贴格式而不是值。 If you want to paste value then change xlPasteFormats to xlPasteValues 如果要粘贴值,然后改变xlPasteFormatsxlPasteValues

Option Explicit
Sub copylocation()
  Dim EC As Long
  Dim X As Long
  Dim Y As Long
  X = Range("B1").End(xlUp).Offset(1, 0).Row
  EC = Range("b1").End(xlToLeft).Offset(0, X).Column
  Windows("Book2").Activate
  Range("b1:AB" & EC).Select
  Selection.Copy
  Windows("Book1").Activate
  Range("b1").Select
  ActiveSheet.Paste
End Sub

暂无
暂无

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

相关问题 复制工作表的最后一行并粘贴到另一工作表的VBA的最后一行 - Copy last row of a sheet and paste in last row of a different sheet VBA VBA-如何将列中的最后一个值复制并粘贴到另一个工作表 - VBA - How to Copy and Paste the last value in a column to another Sheet 复制同一行中不同列的单元格,并粘贴到另一个工作表上同一行的不同列 - Copy cells from different columns on same row, and paste to different columns on same row on another sheet 复制将行从一张纸粘贴到另一张纸 - Copy paste a row from one sheet to another 如果行包含单词“ Hello”,则将该列中所有已填充的单元格复制到另一张纸上,并将其粘贴到“ A”列中 - If row contains word “Hello” copy all filled cells from that column to another sheet and paste it in column “A” Excel可以将某些单元格从一张纸复制/粘贴到另一张纸上,但要稍加改动 - Excel to copy / paste some cells from one sheet to another but with a twist 找到“材料”,复制其单元格并粘贴到另一张纸上 - Find “Material”, copy it's cells and paste into another sheet 如何从一个工作表中复制特定的列并粘贴到第一行中不同范围的另一工作表中? - How to copy specific columns from one sheet and paste in another sheet in a different range at the first row? 如何以编程方式选择多个不同的单元格以复制到剪贴板,然后手动粘贴到另一个工作表 - How to programatically select multiple disparate cells to copy to clipboard and then manually paste to another sheet 自动复制到另一张纸的最后一行 - copy to last row of another sheet automatically
相关标签
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM