简体   繁体   中英

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

and looking to use VBA to APPEND cells from a column, to another one in another sheet. The cells to copy Have to meet a criteria.

Example:

Sheet name "Input":

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

In this example only the Transaction IDs with an Order Status = "Release" will be copied after the already existent ones.

Sheet name "Output":

Transaction ID
90000000
90011111
90033333
90055555
900861515
900861516

Any help with a sample code that i can start with to build my future work?

Thank you!

Ok I will answer my question by myself, who knows maybe it would be helpful for someone else...

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM