+ Reply to Thread
Results 1 to 4 of 4

macro to copy rows based on criteria

  1. #1
    Forum Contributor
    Join Date
    02-11-2008
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    242

    macro to copy rows based on criteria

    Hi,
    I have this sheet,for which I want to create a macro,which will filter on column B and copy all rows having criteria of "OPEX" and paste it to another sheet starting from header row, and the then delete all rows having "OPEX" from master sheet.
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: macro to copy rows based on criteria

    Give this a try, it will give you the option to clear the OPEX sheet first, or not, thus appending the new copied data to the bottom of the existing OPEX data sheet before deleting it from the main sheet.
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    06-22-2011
    Location
    London, ONtario
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: macro to copy rows based on criteria

    it doesnt seem to do anything?
    Im such a newbie at this tho im probably not doing it right.


    I have come up with the following code:

    Sub Copyx()
    Dim RngColF As Range
    Dim i As Range
    Dim Dest As Range
    Sheets("Central").Select
    Set RngColF = Range("H1", Range("H" & Rows.Count).End(xlUp))
    With Sheets("BlessedKateri")
    Set Dest = .Range("A2")
    End With
    For Each i In RngColF
    If i.Value = "X" Then
    i.EntireRow.Copy Dest
    Set Dest = Dest.Offset(1)
    End If
    Next i

    This WORKS! but only to copy the information...

    Do you think you could modify it so that if I delete a row of of the "Central" sheet (which is my master), it will delete it off all the other sheets it is contained it?

    Even that OPEX thing that you did that would clear and replace all the data would work. I think?

  4. #4
    Registered User
    Join Date
    06-22-2011
    Location
    London, ONtario
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: macro to copy rows based on criteria

    Never Mind!


    I visted your site and have figured it out, which was sooooo helpful!

    THANKYOU THANKYOU THANKYOU

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1