Copy a row to another sheet based on value in column A

titushanke

New Member
Joined
Feb 13, 2009
Messages
6
Hi,

I would like to copy rows of data from one worksheet to another (destination worksheet exists, would need to be cleared). The source worksheet contains a "Y" or "N" in column A.


FOR A4 to Q99, filter all rows that have value "Y" in column A of their respective row.

Go to the destination sheet, erase all data in the range A4:Q99.

Paste the filtered data from the source sheet.


Could anybody help me with this in VBA? I don't want to use the filter function as it's many work sheets and I would like to automate it..

Thanks, Titus

PS: Ideally the paste operation should be "paste values", due to existing formatting in the destination sheet.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Just record what you want to do. From your explanation it seems youi wont have to change any code. If required post the code. Will take a look.
 
Upvote 0
Below is what i recorded for my data in Sheet1 Columns A:C pasting the result in sheet2. i had to modify only one line in this code. modify as per your need and i hope it works for you.

Code:
Sub FilterData()

    Columns("A:C").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$C$72").AutoFilter Field:=1, Criteria1:="y"
    Range("A1:C" & Range("A" & Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    Sheets("Sheet2").Select
    ActiveSheet.Paste
    Sheets("Sheet1").Select
    Columns("A:C").Select
    ActiveSheet.Range("$A$1:$C$72").AutoFilter Field:=1
    Columns("A:C").Select
    Application.CutCopyMode = False
    Selection.AutoFilter
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,795
Members
452,943
Latest member
Newbie4296

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