+ Reply to Thread
Results 1 to 4 of 4

Loop to Find Specific Values

  1. #1
    Registered User
    Join Date
    01-09-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    23

    Loop to Find Specific Values

    Hello all, fairly novice with vba programming, especially using loops. I'm hoping someone can provide some help for a problem i'm having.
    I have a column with a list of numbers ordered from smallest to largest. These numbers are cut-off values that have a meaning in my work. Users type a value into another part of the worksheet and I use that value to calculate a high and low bound. What i would then like to happen, is for excel to loop through the list of cut off numbers to see if the user's value is below a cut-off and the higher bound is above the cut-off or vice versa: if the user's value is above a cut-off and the lower bound is below a cutoff.

    I'm not sure how to write this into VBA can anyone help? Thank you!

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Loop to Find Specific Values

    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 use the paperclip icon to open the upload window.

    View Pic
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    01-09-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: Loop to Find Specific Values

    Thank you for your reponse! I've attached a sample worksheet as you suggested that contains two scenarios. When the measured value is entered, I would like to have a different message populate in cell K2 depending on the scenario.

    Scenario #1: K2 should read "Your measured value is below 3.8, but with uncertainty could be above the 3.8 cut-off"
    Scenario #2: K2 should read "Your measured value is above 2.6, but with uncertainty could be below the 2.6 cut-off"

    Thank you for your help!Sample Worksheet.xlsx

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Loop to Find Specific Values

    Hi KS,

    Put this code in your Sheet 1 module and save your book as macro enabled:

    Please Login or Register  to view this content.
    Directions for running the routine(s) just supplied

    If you haven't used macros before you'll need to go to your options - trust center -trust center settings - macro settings
    , the second option down (disable all macros with notification)

    Then - Copy the code to the clipboard

    Open your Workbook

    Press ALT + F11 to open the Visual Basic Editor.

    Click on the Sheet 1 module

    then paste the code

    With the cursor between Sub and End Sub press F5 (F8 to Single Step)

    OR

    Press ALT + Q to close the code window.

    Press ALT + F8 then double click on the macro name
    Last edited by xladept; 01-12-2015 at 03:14 PM.

+ 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] Loop and find specific value or misc value, if misc then not equal to certain values
    By scott.s.fower in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-08-2014, 09:28 PM
  2. Replies: 1
    Last Post: 04-19-2013, 08:30 PM
  3. Macro Loop to Extract Specific Values and Min/Max Values From Column/Rows Range
    By ExcelQuestFL in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-19-2010, 09:19 AM
  4. Macro Loop – Find Specific Times, Extract Date, Average Values of Times
    By ExcelQuestFL in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-25-2010, 02:50 PM
  5. Need to find specific values in range using loop
    By frk1980 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-10-2005, 10:52 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