Results 1 to 4 of 4

Macro to set Flag on dup values

Threaded View

  1. #1
    Registered User
    Join Date
    01-26-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    9

    Macro to set Flag on dup values

    I wrote this macro:

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim CurrentWorksheet As Worksheet
        
        Application.ScreenUpdating = False
        On Error GoTo ErrorHandler
        Set CurrentWorksheet = ThisWorkbook.ActiveSheet
        Dim MaxCount As Integer
        Dim StartCount As Integer
        Dim CountRange As String
        Dim LChangedValue As String
    
    Application.ScreenUpdating = False
        'Test first 200 rows in spreadsheet for uniqueness
        MaxCount = 20
        StartCount = 6
    
        'Clear all flags
        CountRange = "A6:A" & MaxCount
        Range(CountRange).Interior.ColorIndex = xlNone
    
       
        While StartCount < MaxCount
            LChangedValue = "A" & CStr(StartCount)
            test = Application.WorksheetFunction.CountIf(Range("A6:A999"), "A" & CStr(StartCount))
           If test > 1 Then
              Range(LChangedValue).Interior.ColorIndex = 3
              Worksheets("Room and Bed").Range("B" & CStr(StartCount)).Value = "This is text"
           End If
           StartCount = StartCount + 1
        Wend
    
    ErrorHandler:
        Application.EnableEvents = True
        Application.ScreenUpdating = True
    
    
    End Sub
    But it dosn't seem to work the worksheet function isn't working. Can anyone help is there something else I need to do or may have done.
    Last edited by carlysyme; 01-27-2009 at 07:54 AM.

Thread Information

Users Browsing this Thread

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

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