[英]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.