+ Reply to Thread
Results 1 to 8 of 8

Copy and paste Rows based on 2 critera's

  1. #1
    Registered User
    Join Date
    09-03-2018
    Location
    wolverhampton
    MS-Off Ver
    windows 7
    Posts
    33

    Copy and paste Rows based on 2 critera's

    Hi Guy,

    i am after a VBA code which based on 2 lots of selected criteria (from a data validation list/drop down list) will return the relevant rows.

    I have a dashboard sheet which im looking to have 2 drop down selections

    Week No
    Percentage

    Depending on what criteria the user selects the relevant rows from that sheet (Named Week1, week2, e.t.c) is returned that match the percentage required looking at.

    for example.

    If the user selects Week2 from the data validation list and 15% from the second data validation list, i am after a VBA code which looks at Week2 sheet and returns all rows with a percentage of 15% or less to the dashboard.

    i tried recording a macro but i dont know what the function is to search for specific sheet based on selection the macro just always looks at the recorded sheet and the Percentage i filtered.

    Thanks

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Copy and paste Rows based on 2 critera's

    Hi saram1989

    Welcome to the forum.
    Attach a sample workbook . Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.
    To attach a file, click on Go Advanced (below the Edit Window) while you are composing a reply, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and then on Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    09-03-2018
    Location
    wolverhampton
    MS-Off Ver
    windows 7
    Posts
    33

    Re: Copy and paste Rows based on 2 critera's

    hi thanks for the reply see attached work book.
    Ive highlighted in red on the supposed dashboard sheet the 2 criteria selections plus the columns i would love to be able to get automatically copied across based on the criteria,
    i did record a macro but it dosent have the facility to search for the relevent data it just copies across the same data i record every time.
    Attached Files Attached Files

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Copy and paste Rows based on 2 critera's

    Give this a go...
    Please Login or Register  to view this content.
    Last edited by sintek; 09-04-2018 at 04:10 AM.

  5. #5
    Registered User
    Join Date
    09-03-2018
    Location
    wolverhampton
    MS-Off Ver
    windows 7
    Posts
    33

    Re: Copy and paste Rows based on 2 critera's

    That is amazing, thank you so much I would have never of go this far and worked that out,
    Just 2 things ive missed column D so could you direct me how to just add that in the info copied across. i asume its somewhere here

    sr = .Range("C3", .Range("C" & Rows.Count).End(xlUp)).SpecialCells(12).Row
    Set rng = Union(.Range("C" & sr & ":C" & lr).SpecialCells(12), _
    .Range("G" & sr & ":N" & lr).SpecialCells(12))

    also if i was to copy across some new data to my dashboard could i just use the following before the code above to clear any unwanted rows before hand?


    Range("A1:C10").ClearContents
    (Just edit my range of cells to clear)


    Thank so much

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Copy and paste Rows based on 2 critera's

    see red part - only change to include D

    Please Login or Register  to view this content.
    also if i was to copy across some new data to my dashboard could i just use the following before the code above to clear any unwanted rows before hand?
    Are you only wanting to copy the required to dashboard...Not continuous...

    Then make use of ...change 7 to start row of data...
    Please Login or Register  to view this content.
    Last edited by sintek; 09-04-2018 at 04:45 AM.

  7. #7
    Registered User
    Join Date
    09-03-2018
    Location
    wolverhampton
    MS-Off Ver
    windows 7
    Posts
    33

    Re: Copy and paste Rows based on 2 critera's

    Ahh Brilliant new it was somewhere around there learning slowly =)
    Now onto the next great excel idea..
    thank you for your help

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: Copy and paste Rows based on 2 critera's

    .......................................
    Thanks.gif
    Last edited by sintek; 09-04-2018 at 05:53 AM.

+ 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. [SOLVED] Macro to copy rows based on a critera and copy the name of the column
    By dreddster in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-10-2013, 11:34 AM
  2. [SOLVED] how do i copy rows using critera in a formula?
    By Adrian M in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 07:05 PM
  3. [SOLVED] how do i copy rows using critera in a formula?
    By Adrian M in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 09:05 AM
  4. [SOLVED] how do i copy rows using critera in a formula?
    By tim_302ford in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 07:05 AM
  5. [SOLVED] how do i copy rows using critera in a formula?
    By Adrian M in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 06:05 AM
  6. how do i copy rows using critera in a formula?
    By tim_302ford in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  7. [SOLVED] how do i copy rows using critera in a formula?
    By tim_302ford in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  8. [SOLVED] how do i copy rows using critera in a formula?
    By tim_302ford in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM

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