简体   繁体   English

根据单元格值将行从两个或多个Excel工作表复制到另一个

[英]Copying rows from two or more Excel sheets to another based on cell value

enter image description here I don't think that could match the mines, anyway, 无论如何,我在这里输入图片描述我认为这不可能与地雷相提并论,

The difference is copying from more than one sheet to another based on a cell value and not do it with macro VBA but with: 区别在于,根据单元格值从一张以上的纸复制到另一张纸,而不是使用宏VBA而是通过以下方式进行复制:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range).

In fact I tried this but it doesn't give a good result: 实际上,我尝试过此方法,但效果不佳:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    For Each Sh In ThisWorkbook.Sheets
        If Not Sh.Name = "Archive" Then
            If Cells(Target.Row, 3) = "delivered" Then Cells(Target.Row, 3).EntireRow.Copy Sheets("Archive").Range("A" & Rows.Count) _
              .End(xlUp).Offset(1, 0)
        End If 
    Next Sh
End Sub

Thank's for helping me. 谢谢您的帮助。

I post herewith the solution of my question, thank you PEH and thank's for the forum member. 我在此发布我问题的解决方案,谢谢PEH,也感谢论坛成员。

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) If Not Sh.Name = "Archive" Then lastcolumn = Cells(1, Columns.Count).End(xlToLeft).Column If Sh.Cells(Target.Row, 3) = "delivered" And Sh.Cells(Target.Row, lastcolumn) <> "" Then Range(Cells(Target.Row, 1), Cells(Target.Row, lastcolumn)).Copy _ Sheets("Archive").Range("A" & Rows.Count).End(xlUp).Offset(1) End If End If End Sub Private Sub Workbook_SheetChange(ByVal Sh作为对象,ByVal目标作为范围)如果不是Sh.Name =“ Archive”,则lastcolumn = Cells(1,Columns.Count).End(xlToLeft).Column If Sh.Cells(Target.Row, 3)=“已交付”,然后Sh.Cells(Target.Row,lastcolumn)<>“”然后Range(Cells(Target.Row,1),Cells(Target.Row,lastcolumn))。Copy _ Sheets(“ Archive” ).Range(“ A”&Rows.Count).End(xlUp).Offset(1)如果结束则结束如果结束子

暂无
暂无

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

相关问题 根据单元格值将行从一个 Excel 工作表复制到另一个 - Copying rows from one Excel sheet to another based on cell value 以更有效的方式根据单元格值删除两个不同工作表上的行 [VBA Excel] - Delete rows on two different sheets based on cell value in a more efficient way [VBA Excel] 比较两个Excel工作表并找到最大值并复制相邻单元格 - Comparing two excel sheets and finding max value AND copying neighbor cell 从一个Excel到另一个Excel逐个单元复制值 - Copying value cell by cell from one excel to another excel Excel,根据条件在工作表之间复制单元格 - Excel, copying cell between sheets based on criteria 根据单元格值将工作表中的工作表复制并粘贴到其他工作簿 - Copying and pasting sheets from a workbook to a different workbook based on cell value 根据另一个单元格的值将数据从一个单元格复制到另一个单元格 - Copying data from one cell to another based on the value of another cell 根据 7 个工作表中的单元格值隐藏行 excel VBA - Hide rows based on cell value across 7 sheets excel VBA Excel 2007,根据1列中的值将行从一张工作表复制到另一张工作表 - Excel 2007, Copying rows from one sheet to another based on a value in 1 column Excel / Google表格:在“ ISTEXT”条件下将数据从一个单元格复制到另一选项卡和单元格 - Excel/Google Sheets: Copying data from one cell upon “ISTEXT” condition to another tab and cell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM