View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Help to alter code slightly

Hi NoviceBaer,

Try inserting the line:

Range("B" & Target.Row).Value = ""

immediately before the first End If line.


---
Regards,
Norman



"novicevbaer" wrote in message
...

When a user selects from a list box, the product and the cost are
automatically placed into columns a and b. The following code was so
kindly provided to me to ensure there are no duplicate values in column
a. How would I alter the code slightly so that if it does not accept
the duplicate value for column a it will not enter the cost into column
b as well?

Thank you so much for this it is a critical piece of my plan :)




Private Sub Worksheet_Change(ByVal Target As Range)
If ((Target.Row = 1 And Target.Row <= 100) And Target.Column = 1)
Then
If (Range("a" & Target.Row).Value < "") Then
For i = 1 To 100
If (i < Target.Row And Range("a" & Target.Row).Value < "") Then
If (Range("a" & i).Value = Range("a" & Target.Row).Value) Then
MsgBox "entered duplicate value"
Range("a" & Target.Row).Value = ""
End If
End If
Next
End If
End If
End Sub


--
novicevbaer
------------------------------------------------------------------------
novicevbaer's Profile:
http://www.excelforum.com/member.php...o&userid=12567
View this thread: http://www.excelforum.com/showthread...hreadid=319425