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.
Bookmarks