+ Reply to Thread
Results 1 to 4 of 4

Loop to Find Specific Values

Hybrid View

ks26 Loop to Find Specific Values 01-10-2015, 03:06 PM
xladept Re: Loop to Find Specific... 01-10-2015, 06:05 PM
ks26 Re: Loop to Find Specific... 01-12-2015, 08:58 AM
xladept Re: Loop to Find Specific... 01-12-2015, 02:21 PM
  1. #1
    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:

    Option Explicit
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim UB As Single, LB As Single, CO As Single, r As Long, m As String
    If Target.Address = "$E$2" Or Target.Address = "$I$2" Then
    UB = Round(1.1 * Target, 1): LB = Round(0.9 * Target, 1)
    Target.Offset(1) = UB: Target.Offset(2) = LB
    For r = 2 To Range("A" & Rows.Count).End(xlUp).Row
    If Range("A" & r) > LB And Range("A" & r) <= UB Then
    CO = Range("A" & r): Exit For: End If: Next r
                If CO > Target Then
                m = "Your measured value is below " & CO
    m = m & " but with uncertainty could be above the " & CO & " cut-off"
    Else:      m = "Your measured value is above " & CO
    m = m & " but with uncertainty could be below the " & CO & " cut-off"
                End If
    Range("K2") = m: End If: End Sub
    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.
    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

+ 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