Copy row to another sheet based on specific data in a cell

Teffi

New Member
Joined
Aug 3, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi!

I have a set of data on a tab "Tax Hold" this sheet will have new data daily as none of it is static from day to day. Based on if "Trade Skipped" (column T), I would like that row copied onto the sheet named "Skipped Trades". Since the Tax Hold sheet is cleared and new data entered daily I would like the Skipped Trades sheet to stay static so once it is pasted it stays static and any data from the tax hold sheet that meets the critia to copy to Skipped Trades it will always add the row on the next blank row. If this has to be a VBA/Macro is there a button that can be added to make this transfer of data done quickly or is there a formula that can be created to do this.

My experience with Macros is extremely entry level.
1743604526656.png


1743604547539.png
 
Hello @Teffi. Try next code
VBA Code:
Option Explicit

Sub CopyData()
    Dim i           As Long

    Dim ws          As Worksheet
    Set ws = ThisWorkbook.Worksheets("Tax Hold")

    Dim sh          As Worksheet
    Set sh = ThisWorkbook.Worksheets("Skipped Trades")

    Dim iRows       As Object
    Set iRows = CreateObject("Scripting.Dictionary")

    With Application
        .ScreenUpdating = False

        Dim lastRow As Long
        lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row

        Dim data    As Variant
        data = ws.Range("A2:V" & lastRow).Value

        Dim destRow As Long
        destRow = sh.Cells(sh.Rows.Count, "A").End(xlUp).Row

        If destRow < 2 Then
            destRow = 1
        End If

        For i = 1 To UBound(data, 1)

            If data(i, 20) Like "Trade Skipped*" Then
                destRow = destRow + 1
                ws.Range("A" & (i + 1) & ":V" & (i + 1)).Copy _
                        Destination:=sh.Range("A" & destRow)
            End If

        Next i

        .ScreenUpdating = True
    End With

End Sub
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top