Copying entire rows across to new sheet based on two criterias.

KLEINMAN

New Member
Joined
Dec 6, 2015
Messages
20
Hi,

I am trying to create a Macro that looks in my mastersheet and copies across full rows to another sheet based on two criteria's.

For example if master sheet column C is either equal to Jan or Feb it must copy the entire row across to sheet 2.

I have gone through a lot of codes but none that looks at two criteria's.

Any help would be appreciated.

Kind Regards

Steohan van Niekerk
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hello Steohan,

I don't know how your Master sheet is set up, so perhaps the following code may do the task for you:-


Code:
Sub DataTransfer()

Application.ScreenUpdating = False

With ActiveSheet
    .AutoFilterMode = False
With Range("C1", Range("C" & Rows.Count).End(xlUp))
            .AutoFilter 1, "Jan", xlOr, "Feb"
            If Range("C" & Rows.Count).End(xlUp).Row > 1 Then
            .Offset(1).EntireRow.Copy Sheet2.Range("A" & Rows.Count).End(3)(2)
            .Offset(1).EntireRow.Delete
            End If
     End With
[C1].AutoFilter
End With

Application.CutCopyMode = False
Application.ScreenUpdating = True

End Sub

It filters Column C in the active sheet (Master) for either criteria "Jan" or "Feb" and then transfers the relevant row of data to sheet2.
I've attached a link to my test work book for you to peruse:-

https://www.dropbox.com/s/q9c7icdazm26rg0/Kleinman(Transfer to sht2, autofilter).xlsm?dl=0

Click on the "RUN" button to see it work.

I hope that this helps.

Cheerio,
vcoolio.
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,490
Members
448,967
Latest member
visheshkotha

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