+ Reply to Thread
Results 1 to 17 of 17

How to search by two columns using vba?

  1. #1
    Registered User
    Join Date
    07-10-2017
    Location
    Philippines
    MS-Off Ver
    MS OFFICE 2016
    Posts
    38

    Question How to search by two columns using vba?

    These are the columns.

    |---ID---|---NAME---|---GRADE---|---COURSE---|

    I hope you, guys, can help me with this. What I wanted to do is filter data with two columns.

    For example, I ONLY want to filter data that are CS (COURSE) with a GRADE of 900.

    Here's my code on filtering one data only. I've used shape as textbox to search on my recent filter data and base those search on an option button.

    Can you help me work this out?

    Please Login or Register  to view this content.
    Thank you!
    Attached Files Attached Files
    Last edited by asilocyra; 07-16-2017 at 08:47 PM.

  2. #2
    Forum Contributor
    Join Date
    10-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2016 in 2024
    Posts
    857

    Re: How to search by two columns using vba?

    Could you use something like:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-10-2017
    Location
    Philippines
    MS-Off Ver
    MS OFFICE 2016
    Posts
    38

    Re: How to search by two columns using vba?

    Quote Originally Posted by maym View Post
    Could you use something like:

    Please Login or Register  to view this content.
    I've updated my post, maybe you can help me with it?

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: How to search by two columns using vba?

    Upload sample...
    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 [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  5. #5
    Registered User
    Join Date
    07-10-2017
    Location
    Philippines
    MS-Off Ver
    MS OFFICE 2016
    Posts
    38

    Re: How to search by two columns using vba?

    Quote Originally Posted by sintek View Post
    Upload sample...
    Ohhh. Hi, again. Thank you for looking into this!

    https://drive.google.com/open?id=0B4...0VjWXQzTmN6ZVE

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: How to search by two columns using vba?

    That huge file of your with nothing in.....

  7. #7
    Registered User
    Join Date
    07-10-2017
    Location
    Philippines
    MS-Off Ver
    MS OFFICE 2016
    Posts
    38

    Re: How to search by two columns using vba?

    Quote Originally Posted by sintek View Post
    That huge file of your with nothing in.....
    Yea, I'm also wondering why it's like that. :O

  8. #8
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: How to search by two columns using vba?

    32.6MB i suggest you create a new sheet with criteria.....re upload
    Just takes up to much processing power and time when we have to work with it...
    Originally Posted by Pete_UK
    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.

  9. #9
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: How to search by two columns using vba?

    I may be misunderstanding what you're asking, but assuming you have your titles in the range "A2:E2", and all the data underneath them, this will copy all rows that meet the two criteria and paste them into sheet 3 with the headings from sheet 1
    Please Login or Register  to view this content.
    Edit: I now see that you need dynamic user-inputted search criteria nvm
    Last edited by danielexcelvba; 07-14-2017 at 11:20 AM.

  10. #10
    Registered User
    Join Date
    07-10-2017
    Location
    Philippines
    MS-Off Ver
    MS OFFICE 2016
    Posts
    38

    Re: How to search by two columns using vba?

    Quote Originally Posted by sintek View Post
    32.6MB i suggest you create a new sheet with criteria.....re upload
    Just takes up to much processing power and time when we have to work with it...
    Hi! Sorry it took me long to get back to you. Anyways, I've already uploaded the file and thank you for teaching me how to do it.

  11. #11
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: How to search by two columns using vba?

    So please explain what you want to achieve...
    You want to filter sheet 1 based on those two criteria.....And then....Copy the info to Sheet3

  12. #12
    Registered User
    Join Date
    07-10-2017
    Location
    Philippines
    MS-Off Ver
    MS OFFICE 2016
    Posts
    38

    Re: How to search by two columns using vba?

    Quote Originally Posted by sintek View Post
    So please explain what you want to achieve...
    You want to filter sheet 1 based on those two criteria.....And then....Copy the info to Sheet3
    Yes, that's what i wanted to do but i've been stuck there because i don't know how to filter based on two criteria.
    But I came up with something like this but I didn't get any far.

    Please Login or Register  to view this content.

  13. #13
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: How to search by two columns using vba?

    This will give you an idea...Will filter Active Sheet based on your stipulated two criteria then copy the filtered rows to Sheet3...If none available will bring up a message..
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    07-10-2017
    Location
    Philippines
    MS-Off Ver
    MS OFFICE 2016
    Posts
    38

    Re: How to search by two columns using vba?

    Quote Originally Posted by sintek View Post
    This will give you an idea...Will filter Active Sheet based on your stipulated two criteria then copy the filtered rows to Sheet3...If none available will bring up a message..
    Please Login or Register  to view this content.
    I got it working but how do I pass value to a criteria using a shape or textbox from a control form?

  15. #15
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: How to search by two columns using vba?

    Try something like this...
    Please Login or Register  to view this content.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    07-10-2017
    Location
    Philippines
    MS-Off Ver
    MS OFFICE 2016
    Posts
    38

    Re: How to search by two columns using vba?

    Quote Originally Posted by sintek View Post
    Try something like this...
    Please Login or Register  to view this content.
    THANK YOU! You saved me, AGAIN! I've been struggling here for days just to get that result XD
    THANK YOU SO MUCH! You're my life saver hahaha

    Anyways, I also came up with something like that, but it doesn't insert filtered data to another sheet.

    Please Login or Register  to view this content.

  17. #17
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: How to search by two columns using vba?

    Glad i could help...thanks for rep +

+ 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. Search box for two columns A & B
    By Billy69 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-06-2015, 04:50 PM
  2. Replies: 4
    Last Post: 12-02-2014, 05:17 PM
  3. Replies: 6
    Last Post: 08-22-2014, 08:47 AM
  4. [SOLVED] .Find Help - Search only in specific columns (or ignore other columns)?
    By NewYears1978 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2014, 11:32 AM
  5. Replies: 3
    Last Post: 04-17-2013, 07:09 PM
  6. search in different columns
    By Dien in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-30-2008, 05:00 AM
  7. search 2 Columns Please
    By Steved in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-14-2006, 02:10 PM

Tags for this Thread

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