+ Reply to Thread
Results 1 to 6 of 6

Match 2 user inputs across 2 rows and copy row

  1. #1
    Registered User
    Join Date
    10-24-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    6

    Question Match 2 user inputs across 2 rows and copy row

    Hi all!

    Really stuck with something on a project we're putting together and hoping you guys can help, i'm by no means an excel/VBA expert and if this can be done using formula then i apologise for the post in this area.

    So the sheet we have has a ton of columns, we're interested in having 2 search cells on a sheet away from our raw data sheet(same workbook) where 2 strings can be entered and if found, have the entire matched rows copied from the raw sheet to a new sheet.

    It seems simple enough at first but whats getting me stuck is that the data from either user input can be found in either column.

    So for example, the user may input "Water" in one search box and "Bottle" in the other. I need to find a way to search through columns A and B in the entire data sheet and find rows where Water AND Bottle are found on the same row in either column and either order (Water | Bottle or Bottle | Water) and return the rows onto a new sheet. Moving the data to make it easier isn't an option unfortunately

    The extracted data rows would look like:

    Water | Bottle | Other Data
    Bottle | Water | Other Data
    Bottle | Water | Other Data
    Water | Bottle | Other Data

    Im absolutely stuck, my google skills have failed me and im hoping you ladies and gents may have a solution. I've looked (briefly) to see if this has been asked before and couldn't find anything.

    Any help is much appreciated.

    Thanks,
    Matt.

    *Edited to clarify certain points
    Last edited by Mattwood; 10-24-2017 at 02:38 PM.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Match 2 user inputs across 2 rows and copy row

    I think this could be accomplished with helper columns on the data sheet and a pivot table. We'll need to see more to make an assessment.

    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.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    10-24-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    6

    Re: Match 2 user inputs across 2 rows and copy row

    Hey,

    Thanks for the reply. I'll look at getting that done and uploaded sometime this evening.

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Match 2 user inputs across 2 rows and copy row

    It turns out that it was simple enough to set up a test case. Normally I (and others) don't have the time to set them up especially when there is a lot of data involved. In this case, not a lot of data or setup is required.

    I have it all on one page so I could test it easier.

    The data is in columns A:E with helper columns in F, G & H.

    The formula in F =IF([@[Keyword 1]]=$K$3,[@[Keyword 2]]=$K$4,FALSE) - which essentially says if Keyword 1 matches the input Keyword 1 (Cell K3), then test to see if Keyword 2 matches the other Keyword. There is a similar formula in column G to do the test the other way.

    Column H =OR([@[Match 1]],[@[Match 2]]) which says if either condition is True, then it's a good combination.

    Columns O and Q are pivot tables in their own right. That they do is get a unique list of the keywords from the database. I overlaid them with a named dynamic range (sort of an advanced topic, read up on it here: http://www.utteraccess.com/wiki/Offs...Dynamic_Ranges) and used that for a list-type data validation (read up on that here: http://www.utteraccess.com/wiki/Data_Validation). The result is I get drop down lists for cells K3 and K4.

    There are two issues with using a pivot table:

    1. You have to refresh it after making your selections.

    2. If the selections yield no results, then everything comes out FALSE and FALSE is the only option for the filter on the pivot table so EVERYTHING shows. It will be obvious if this happens. You won't be able to select TRUE for the pivot table filter.

    You should have enough to adapt this to your situation. Let me know if you need help with the pivot table.
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Match 2 user inputs across 2 rows and copy row

    With macro.
    Is that it ?

    Sheet1 - conditions
    Sheet2 - data (bottle, water)
    Sheet3 - results
    Attached Files Attached Files
    Last edited by mjr veverka; 10-24-2017 at 05:30 PM.

  6. #6
    Registered User
    Join Date
    10-24-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    6

    Red face Re: Match 2 user inputs across 2 rows and copy row

    Hey,

    Thanks so much for the help, both of you.

    I managed to get both of your solutions working but in the end the macro was a lot easier for me to adapt into my worksheet.

    Again, thanks so much for how fast you got back to me, very much appreciated!

    Cheers!

+ 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. Replies: 5
    Last Post: 09-08-2013, 10:09 AM
  2. VBA macro with user inputs to be used on any file
    By cheese01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2013, 10:29 AM
  3. VBA: Create User Form That Takes Variable User Inputs
    By sanjeevpandey in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-18-2013, 06:14 PM
  4. Match inputs in one column with data from another if >50% of their consec letters match
    By TaskinRahman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-24-2012, 01:47 AM
  5. Passing inputs from one user form to another
    By daymaker in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-18-2011, 11:02 AM
  6. Unknown number of user inputs
    By learning_vba in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-24-2010, 04:33 PM
  7. Macro with user defined inputs
    By Nigel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-25-2007, 07:24 PM
  8. Clearing user inputs.....
    By tom300181 in forum Excel General
    Replies: 3
    Last Post: 03-28-2005, 11:55 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