Results 1 to 5 of 5

VBA match 4 conditional values at once with Select Case.

Threaded View

  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 ?


    Sub findpackage()
    
    Dim sheet As String
    
    Range("B3").Value = ComboBox1 
    sheet = ComboBox1.Value
    Worksheets(sheet).Activate
    
    
    
    Dim length As Double
    Dim height As Double
    Dim width As Double
    Dim mass As Double
    
    (Declare Array)?
    
    (Select Case Arguments)?
    
    
    End Sub
    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.

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. 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