Hi all,
I am struggling with coding one condition: Do not allow the user to mark record if cell value appears in column more than once.
Here is what I have:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sRange As Range
Dim nResult As Long
Dim tRange As Range
Dim x As Double
Dim LastRow As IntegerDim DupCheck As String
Set sRange = Range("EG2:EG" & Cells(Rows.Count, 1).End(xlUp).Row)
Set tRange = Range("BA2:BA" & Cells(Rows.Count, 1).End(xlUp).Row)
For x = 2 To LastRow
LastRow = ActiveSheet.Cells(Rows.Count, 1).End.Row
DupCheck = Application.WorksheetFunction.CountIf(tRange, x)
Next x
If Target.Cells.Count > 1 _
Or Intersect(Target, Range("EG2:EG" & Cells(Rows.Count, 1).End(xlUp).Row)) Is Nothing Then Exit Sub
If UCase(Cells(Target.Row, "EE")) <> "PAID" Or (UCase(Cells(Target.Row, "EE")) = "PAID" And UCase(Cells(Target.Row, "EF")) = "REVERSAL") Then Exit Sub
If UCase(Cells(Target.Row, "EE")) = "PAID" And DupCheck > 1 Then Exit Sub
If Target = vbNullString Then
Target = "RK"
Else
Target = vbNullString
End If
Range("EN2") = Application.WorksheetFunction.CountIf(sRange, "RK")
If Range("EN2") >= Range("EM2") Then
nResult = MsgBox( _
Prompt:="You have already selected the minimum Risk Based Claims. Do you want you want to select the Random Claims now?", _
Buttons:=vbYesNo)
If nResult = vbNo Then
Exit Sub
Else
MsgBox "Please run the Random_Claims_Selection macro."
End If
End If
Application.ScreenUpdating = True
End Sub
It's column BA and DupCheck.
I posted this on another forum (http://www.mrexcel.com/forum/showthr...?t=567053) but am not getting any response.
I really need help!
Thank you,
Gos-C
Bookmarks