簡體   English   中英

VBA附加-根據條件將單元格從一張紙復制到另一張紙

[英]VBA Append - copy cells froma sheet to another based to a criteria

並希望使用VBA將一列中的單元格追加到另一張工作表中。 要復制的單元必須符合條件。

例:

Sheet name "Input":

Order Status    Transaction ID
Release         90033333
Release         90055555
cancel          90077777
Release         900861515
Release         900861516

在此示例中,只有訂單狀態為“發布”的交易ID會在已經存在的交易ID之后被復制。

工作表名稱“輸出”:

Transaction ID
90000000
90011111
90033333
90055555
900861515
900861516

我可以從示例代碼開始構建未來的工作嗎?

謝謝!

好的,我會自己回答我的問題,誰知道這可能會對其他人有所幫助...

Sub TestA()


Application.ScreenUpdating = False

Dim cell As Range
Dim OrderID As String
Dim LastRow As Long

For Each cell In Sheets("RogersEmailData").Range("A:A")
  If cell.Value = "Release" Then
    OrderID = cell.Offset(0, 1).Value

    With Sheets("approved orders")
    .Range("A" & .Rows.Count).End(xlUp).Offset(1, 0).Value = OrderID
    End With

 End If
Next cell

Application.ScreenUpdating = True


End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM