+ Reply to Thread
Results 1 to 5 of 5

locate a value among many

  1. #1
    Forum Contributor
    Join Date
    10-09-2006
    Posts
    212

    locate a value among many

    Hi there I have attached an example. I basically need to find and highlight a cell when the number matches. I would like to select the color and the value I am looking for. My excel has limited CF's which is why I am turning to the wonderful people here.

    Kindest regards,
    Martin.
    Attached Files Attached Files

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    Hi Martindelica,

    Try this code:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    10-09-2006
    Posts
    212
    Actually, it works great on the sheet I posted, but when I copy it into my other sheet I get an error 13. It has a problem with this line " If ce2.Value = ce.Value Then".

    I got it. Just got two other things. Can I get the macro to run automatically without having to goto tools/macros and run. Cant it run automatically in the background?

    And is there somethin gI can add to the code that will hihglight the cell even though the number is not an exact match. Like if I enter in cell A1 to allowance both sides of the exact number. EG If I want to see the values that are a match of 25 and colro them red, and in cell A1, I put a 2, then if the number is 23, 24, 25, 26, 27 the cell will light up red.

    Kindest regards,
    Martin.
    Last edited by Martindelica; 02-02-2008 at 03:27 AM.

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    Hi Martin,

    Try this code, it should do both requests (automated & color range of cells based on value in cell A1):
    Please Login or Register  to view this content.
    Put this code into the 'ThisWorkbook' module in the VB Editor.
    - Press ALT+F11 to open VB Editor
    - In left pane, double-click 'ThisWorkbook'
    - Copy & Paste the above code
    - Remove any previous code you had added for this issue (from ThisWorkbook or from any specific sheet's code)
    - Close the VB Editor and test.

  5. #5
    Forum Contributor
    Join Date
    10-09-2006
    Posts
    212
    Sweet, works like a charm. The only thing is when I input the code into my real sheet and not the example I get an error. The range in the real sheet is
    E2:M2 and C6:O18, instead of D2:L2 and E7:J12. I used the example as a small file to upload. Everything else is the same, but when I change the ranges I get an error. Is there a way I can change the ranges and still have it work? because in the example it exactly what I want.

    Kindest regards and thanks veru much,
    Martin.

+ 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