+ Reply to Thread
Results 1 to 13 of 13

How to check for Plus/Minus condition (Macro)

  1. #1
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,165

    How to check for Plus/Minus condition (Macro)

    With out using Conditional Formatting, how can I check a cells value if it can fall within a range of +\-.002?
    I have this code but it seems to have limitations.

    Please Login or Register  to view this content.
    I am stumbling on how to check the cell to see if it complies to a +\-.002 scenario and if it does, clear the contents of another cell. The above code will clear the cell if the value is positive, but not negative.

    All help is appreciated.
    Regards

    Rick
    Win10, Office 365

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Bit confused from your code on what you are really trying to do, but from your words is this what you are chasing???

    Please Login or Register  to view this content.

    rylo

  3. #3
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,165
    Peering into my mind is dangerous!

    Here is my scenario, I am attempting to loop thru many rows in two columns to check a condition.
    The condition is a tolerance of +\-.002 of the value in cells from two columns, a range. I am taking the average value of the two cells and testing for conformance of +\-.002 from Zero. If the value is out of tolerance the code does something.

    Conditional Formatting is limited on what I can do, or maybe its me that's limited?

    The .ClearContents can be ignored, I resolved that one. (I feel like such a grown up).

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Rick

    Perhaps an example file showing what you want to happen for a given data set would help clarify.


    rylo

  5. #5
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,165
    See attached Excel file, and please, criticism is accepted, however I have feelings
    Also attached is the macro to run the data. I keep macros in a "personal.xls" file.

    File "Template MPC 3061494-1 Profile .006-.004 JNxxxxx A.txt" needs to be renamed to "Template MPC 3061494-1 Profile .006-.004 JNxxxxx A.xls" and file "Module1_OOT_Profiles_A.txt" needs to be renamed to "Module1_OOT_Profiles_A.bas".
    Attached Files Attached Files
    Last edited by Rick_Stanich; 06-21-2007 at 10:03 AM.

  6. #6
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,165
    I should have zipped both files :shrug:
    Both files in a ZIP format.
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Rick

    Can you zip the spreadsheet(s).


    rylo

  8. #8
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,165
    Here attached, is the excel file with the macro imported and tied to a Button on the spread sheet.
    The macro only clears cell contents with no data is available. I have populated the cells with data, not real data.
    My goal is to ensure validation of a condition, example, +\-.0020.
    Last edited by Rick_Stanich; 06-22-2007 at 05:07 PM.

  9. #9
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Have you considered a custom boolean function.
    Please Login or Register  to view this content.
    Replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,165
    This is the direction I need!
    I can do quite a bit in VB/VBA, but I do not know everything!

  11. #11
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,165
    Quote Originally Posted by mikerickson
    Have you considered a custom boolean function.
    Please Login or Register  to view this content.
    Replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    Add one more item to the "Do not know list".
    How is this function used?

  12. #12
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    How to use it? Replace Excel's boolean function "=" with the boolean function almostEqual.

    I haven't looked at your sheet yet (busy week), but based on first post:
    This routine will color those cells in column D that are within .002 of the value in column F.
    Please Login or Register  to view this content.
    The same could be gotten with Conditional Formatting set to custom formula =almostEqual($D1,$F1) in D1 and copied to the rest of the column

    The custom forumula =(ABS($D1-$F1)<.002) would do the same, but without the UDF.

    I hope this helps.

  13. #13
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,165
    I see the light (logic) now!
    this has been most helpful!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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