Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Randy,
Please try to keep followup questions in the original thread so people know what you're referring to. If you want to do this via VBA code, you can put it in the Worksheet_Change event. Here's an example: Private Sub Worksheet_Change(ByVal Target As Range) If Not Application.Intersect(Target, _ Rows(2)) Is Nothing Then If Application.WorksheetFunction.CountIf( _ Rows(2), "=" & Target.Value) 1 Then MsgBox "Please enter a unique value." Target.ClearContents Target.Select End If End If End Sub Just right-click the tab of the worksheet you'd like to monitor, then select View Code. Paste this code into the resulting code pane. -- Regards, Jake Marx www.longhead.com Randy wrote: From a previous post..... When entering a cell value and a dupilicate exists in the same cell different column, I would like a pop up that says "Please Enter a Unique Value" All help would be appreciated Thanks! You can do this with Data | Validation. Just select row 2, select Data | Validation, then select Custom and enter this formula: =COUNTIF($2:$2,"=" & A2)=1 Under the Error Alert tab, you can enter the error message you'd like displayed when users enter bad data. Unfortunately, copying/pasting will destroy the data validation, so this will not stop someone from copying/pasting data onto row 2. ...I would like to add this to an existing macro that I am already using Thanks! |