+ Reply to Thread
Results 1 to 5 of 5

VBA match 4 conditional values at once with Select Case.

  1. #1
    Registered User
    Join Date
    08-25-2012
    Location
    United States
    MS-Off Ver
    Excel 2016
    Posts
    11

    VBA match 4 conditional values at once with Select Case.

    I am building a VBA search function across 3 product sheets (one at a time) for determining the next available size of packaging for a part (see attached example). Package chooser Rev5.xlsx


    The search is based on 4 input criteria (length, width, height and mass) and returns the record containing the next largest dimensions across each of these values (being >= to the input values).

    The combined part volume or aggregate measurements are not a decision criteria. The product sheets need to remain clean and be update-able by users.

    I would like the output to be similar to this example https://www.youtube.com/watch?v=QOxhRSCfHaw ("Excel VBA Loop to Find Records Matching Search Criteria") where a matching row is copied and pasted to the search page.

    I have setup a (non-VBA) drop-down combobox with a data validation list (Sheet Directory) for the the search page which should activate the chosen worksheet. (thus allowing users to add new product sheets without modifying VBA code).

    I am unclear on the best way to manage this sheet activation in VBA and then the procedure for looping through the variables and only return records which meet all of the criteria at once. Any record containing any value not meeting the search condition would not be considered a match.

    The inputs:

    Length Width Height Mass
    240, 33, 18, 160

    Would match a row containing:

    Length Width Height Mass
    250.5, 35.40, 20, 187.44

    But not be a match for:

    Length Width Height Mass
    250.5, 35.40, 20, 150



    The procedure I have so far is possibly declaring a multidimensional array for the L,W,H,M column variables and creating a conditional operator of >= all "L,W,H,M" input values. Can I simplify things with a Select Case statement ? Or Select Case Is ?


    Please Login or Register  to view this content.
    Am I barking up the right tree?

    Any help would be greatly appreciated!

    Cross Posted Here:

    http://www.mrexcel.com/forum/excel-q...lect-case.html

    http://www.excelguru.ca/forums/showt...itional-values

    http://www.vbaexpress.com/forum/show...th-Select-Case
    Last edited by digibay; 10-23-2015 at 11:54 AM.

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: VBA match 4 conditional values at once with Select Case.

    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
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: VBA match 4 conditional values at once with Select Case.

    Cross posting.
    Attached Files Attached Files
    Last edited by skywriter; 10-22-2015 at 02:21 AM.

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,592

    Re: VBA match 4 conditional values at once with Select Case.

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

  5. #5
    Registered User
    Join Date
    08-25-2012
    Location
    United States
    MS-Off Ver
    Excel 2016
    Posts
    11

    Re: VBA match 4 conditional values at once with Select Case.

    Code below for a working solution from Skywriter (preserving the simple non VBA dropdown list)


    Please Login or Register  to view this content.

+ 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. If 4 cells have specific values then x; Select Case?
    By cocacrave in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-04-2015, 08:19 AM
  2. [SOLVED] Select Case - if no match issue
    By D_N_L in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-12-2014, 11:57 AM
  3. [SOLVED] how to set select case values from sheet 2 vba code
    By sspreyer in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 08-29-2013, 12:27 PM
  4. Replies: 9
    Last Post: 06-04-2012, 08:00 AM
  5. Case Select compile error "Case without case select"
    By coasterman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2012, 06:50 AM
  6. Case Select....The alternative method for long "Select Case"
    By kimyap in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-22-2008, 01:24 AM
  7. [SOLVED] Select Case Conditional Formatting Sub?
    By RCW in forum Excel General
    Replies: 2
    Last Post: 02-05-2005, 07:06 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