+ Reply to Thread
Results 1 to 6 of 6

How do I copy and past selected rows to a new sheet when multiple conditions are met?

  1. #1
    Registered User
    Join Date
    08-28-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    26

    How do I copy and past selected rows to a new sheet when multiple conditions are met?

    Hello

    I'm an event manager and am setting up a database to record the event details, including 'status: namely, whether an event's booking status is 'Enquiry' or 'Provisional' or 'Confirmed'. I want to move the 'Provisional' and 'Confirmed' records to a new sheet (don't want to use filters in sheet 1, as others will use this database and I will only give them access to the sheet 2).

    I'm new to VBA, so am searching for some code that might help. Assume at this stage, there are just three columns: Status, Event Type, Event Date. I have found the following code and tested this to see that it works, which it does:


    Sub SelectAndMoveData()
    '
    ' SelectandMoveData Macro
    '
    ' Keyboard Shortcut: Ctrl+q
    '

    Columns("A:C").Select
    Selection.AutoFilter
    Range("C1").Select
    ActiveSheet.Range("$A$1:$C$10000").AutoFilter Field:=1, Criteria1:="Provisional"
    Range("A1:C1000").Select
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    ActiveSheet.Next.Select
    Range("A1").Select
    ActiveSheet.Paste
    Range("A1").Select
    ActiveSheet.Previous.Select
    Range("A1").Select
    Application.CutCopyMode = False
    Selection.AutoFilter
    Range("A1").Select

    End Sub



    I've found many examples such as this which allow just ONE criteria to be met. However, I'm trying to adjust it to make it work for MORE THAN ONE criteria, which would select the row whether 'Provisional' OR 'Confirmed'. Sadly, I'm floundering to get the syntax right!

    Any suggestions, please, for an elegant solution?

    Many thanks
    Terri H

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: How do I copy and past selected rows to a new sheet when multiple conditions are met?

    Changing this line:

    Please Login or Register  to view this content.
    To this will account for the 2 you mentioned.

    Please Login or Register  to view this content.

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,887

    Re: How do I copy and past selected rows to a new sheet when multiple conditions are met?

    Terri;
    Welcome to the Forum.

    Change this line of code
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    08-28-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: How do I copy and past selected rows to a new sheet when multiple conditions are met?

    Thank you. This works. By the way, apologies for not including the Code Tags - this is my first thread, but I'll know better next time!

    Quote Originally Posted by JOHN H. DAVIS View Post
    Changing this line:

    Please Login or Register  to view this content.
    To this will account for the 2 you mentioned.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-28-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: How do I copy and past selected rows to a new sheet when multiple conditions are met?

    Thank you. This works. By the way, apologies for not including the Code Tags - this is my first thread, but I'll know better next time!

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: How do I copy and past selected rows to a new sheet when multiple conditions are met?

    Quote Originally Posted by Terri H View Post
    Thank you. This works. By the way, apologies for not including the Code Tags - this is my first thread, but I'll know better next time!
    You're welcome. Glad to help out and thanks for the feedback.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy rows into a new sheet as per set conditions
    By walchase in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 12-06-2012, 03:51 PM
  2. function/formula to copy/past multiple data rows in Excel worksheet
    By djerin in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 05-22-2009, 09:16 AM
  3. Copy Rows from selected Sheet to New Sheet based on Cell Value
    By joemcmillen in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 04-03-2008, 03:44 PM
  4. Copy Selected Rows To Another Sheet
    By bjwade62 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2006, 06:57 PM
  5. [SOLVED] copy selected rows to new sheet
    By Bryan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-01-2005, 01:06 AM

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