Results 1 to 4 of 4

Match a cell against a named range

Threaded View

  1. #1
    Registered User
    Join Date
    12-18-2009
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    18

    Match a cell against a named range

    I am struggling with most probably a straight forward problem, but here goes. I want to write some VB coding to match cell values to a list I have already made "Stock" so that only rows with the values that don't match get highlighted in red. My problem is being able to reference the list "Stock" in VB - is it possible?

    Sheet 1 contains my named ranges, and sheet 2 is where data gets entered. So basically is there any way to say if Activecell is found in named range then color no fill, if not color red.

    Thanks in advance. I'm sure it's not as simple as I'm trying to make it. Eventually it might build to names and not just numbers that I'm looking up as well.

    Sub ValTest()
        
    
        Dim numOfRecs As Integer
    
        ActiveWorkbook.Names.Add Name:="Office", RefersTo:="Sheet1!$A$2:$A$25"
        '---------------------
        'Start - Validate Office
        '---------------------
        Sheet2.Activate
        Range("A2").Select
    
        numOfRecs = 0
    
        Do Until ActiveCell.Value = ""
    
            ' Validate Office
            If ActiveCell.Value = ??????? Then
                ActiveCell.Interior.ColorIndex = 3 'Red
            Else
                ActiveCell.Interior.ColorIndex = 0 'No Fill
            End If
    
            numOfRecs = numOfRecs + 1
    
            ActiveCell.Offset(1, 0).Select
    
        Loop
    
    
    ' Go to first cell.
        Range("A1").Select
    
       
    End Sub
    Last edited by bignowa; 11-02-2011 at 06:27 PM.

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