How to copy specific columns and filtered rows into another worksheet

Jyde

Please, I need some help with my code. I filtered some rows using VBA and would like to copy only two columns instead of all columns.

Public Sub CheckPrKey()
lastRow = Worksheets("ETM_ACS2").Range("A" & Rows.Count).End(xlUp).Row

  For r = 2 To lastRow
     If Worksheets("ETM_ACS2").Range("I" & r).Value = "Y" And Worksheets("ETM_ACS2").Range("N" & r).Value < "100" Then
   Worksheets("ETM_ACS2").Range("D, N" & r).Copy
   **Worksheets("ETM_ACS2").Rows(r).Copy**
   
   Worksheets("dashboard").Activate
   lastRowdashboard = Worksheets("dashboard").Range("B" & Rows.Count).End(xlUp).Row
   Worksheets("dashboard").Range("A" & lastRowdashboard + 1).Select
   
   ActiveSheet.Paste
End If

Next r
ActiveCell.Offset(1, 0).Select

End Sub
Mik

I'm not sure that got the point, but try.

Public Sub CheckPrKey()
    lastRow = Worksheets("ETM_ACS2").Range("A" & Rows.Count).End(xlUp).Row
    lastRowdashboard = Worksheets("dashboard").Range("B" & Rows.Count).End(xlUp).Row
    
    With Worksheets("ETM_ACS2")
        For r = 2 To lastRow
                
            If .Range("I" & r).Value = "Y" 
                If .Range("N" & r).Value < "100" Then

                    Worksheets("dashboard").Range("A" & lastRowdashboard + 1)=.Range("D" & r)
                    Worksheets("dashboard").Range("B" & lastRowdashboard + 1)=.Range("N" & r)
                    lastRowdashboard =  lastRowdashboard +1             
                End if
            End If
        Next r
    End With

End Sub

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Copy filtered rows from worksheet to the last row of another worksheet

copy non empty rows from a subset of columns to another worksheet

Copy rows on condition to another Worksheet

Copy specific cell to another worksheet

How to copy cells of specific colour of a worksheet and paste them in another workbook

How to copy a specific range from one worksheet to another worksheet in another workbook

Copy to dynamically created rows in another worksheet

Copy specific cell in column and paste in another worksheet

Copying specific columns conditionally to another worksheet

How do I copy some specific columns from a given range which is auto filtered in Excel VBA?

How to copy rows of specific columns based on a criteria (and then continuously update)?

How to copy specific rows and columns from a spreadsheet to notepad?

Count Visible Rows in Filtered Worksheet

How can I copy specific rows based on a cell value in that row and paste it to a matching worksheet

How can you Create a copy of a worksheet by iterating through another while excluding certain rows in a array.?

How to copy specific rows from DataTable to another one

How to Copy and Paste Rows starting from a specific cell in another sheet

How to copy rows with a specific value in a column to another sheet?

How to copy specific columns of data from one sheet to another

Select and copy a specific number of filtered rows using VBA in excel

Copy rows filtered on a search criteria from one table to another in MySQL

How to copy a range to another worksheet with for each loop?

Excel Interop: How to copy a worksheet to another workbook?

Excel VBA - Find and copy non-matching rows to another worksheet

copy data rows with NULL column to another range in the same worksheet

Excel VBA: Only copy rows based on 2 criteria to another worksheet

Perform check on two columns, Copy column by column another Worksheet

Copy and Paste Specific Cells from one worksheet to another

Copy Specific Rows and Columns from a .csv into .xlsx

TOP Ranking

HotTag

Archive