Option Explicit
Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Dim MyCells As Range
Dim aLen As String
Set MyCells = Range("A2,A6,A10")
aLen = Mid(Target, 11, 1)
Application.EnableEvents = False
Dim varRows() As Variant
Dim i As Long, myFirst As Long, myLast As Long
Dim myRng As Range
Dim oRange As Range
myFirst = Columns("I").Column
myLast = Columns("Q").Column
ReDim Preserve varRows(myLast - myFirst)
'/ Finds the row number of the longest column between I and Q
For i = myFirst To myLast
varRows(i - myFirst) = Cells(Rows.Count, i).End(xlUp).Row
Next
If Not Application.Intersect(MyCells, Range(Target.Address)) Is Nothing Then
Set oRange = Worksheets(1).Range("I1:Q" & Application.Max(varRows)).Find(Target, lookat:=xlWhole)
If Not oRange Is Nothing Then
MsgBox oRange & " - is a duplicate entry, see cell " & oRange.Address
Target.Copy Range("X" & Rows.Count).End(xlUp)(2)
Range("X" & Rows.Count).End(xlUp).Offset(, 1) = Date
Target.Select
Target.ClearContents
Application.EnableEvents = True
Exit Sub
Else
'/ This is the message box code to delete when not wanted any more, Leave the space "Else" to "End If" blank.
MsgBox "Non duplicate entry, and will be posted in I to Q columns." & vbCr & vbCr & _
"(You can delete this message any time you want." & vbCr & _
"It is here to help you see what the code is doing.)"
End If
If Target.Address = "$A$2" Then
Cells(2, 1).Copy Range("C" & Rows.Count).End(xlUp)(2)
If aLen = "S" Then Cells(2, 1).Copy Range("I" & Rows.Count).End(xlUp)(2)
If aLen = "M" Then Cells(2, 1).Copy Range("J" & Rows.Count).End(xlUp)(2)
If aLen = "L" Then Cells(2, 1).Copy Range("K" & Rows.Count).End(xlUp)(2)
End If
If Target.Address = "$A$6" Then
Cells(6, 1).Copy Range("E" & Rows.Count).End(xlUp)(2)
If aLen = "S" Then Cells(6, 1).Copy Range("L" & Rows.Count).End(xlUp)(2)
If aLen = "M" Then Cells(6, 1).Copy Range("M" & Rows.Count).End(xlUp)(2)
If aLen = "L" Then Cells(6, 1).Copy Range("N" & Rows.Count).End(xlUp)(2)
End If
If Target.Address = "$A$10" Then
Cells(10, 1).Copy Range("G" & Rows.Count).End(xlUp)(2)
If aLen = "S" Then Cells(10, 1).Copy Range("O" & Rows.Count).End(xlUp)(2)
If aLen = "M" Then Cells(10, 1).Copy Range("P" & Rows.Count).End(xlUp)(2)
If aLen = "L" Then Cells(10, 1).Copy Range("Q" & Rows.Count).End(xlUp)(2)
End If
End If
Application.EnableEvents = True
End Sub