View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Gregory Winters Gregory Winters is offline
external usenet poster
 
Posts: 7
Default Data Validation in Calculated Cells - P.S.

I guess I should also mention that since this is coming from a Copy & Paste
function, that the code should be able to continue 'working' until all
duplicates have been removed, thanks.

"Bernie Deitrick" wrote:

Greg,

Do you only require that consecutive cells not have the same value, or do you not want to have any
value in column C repeated (Does C2 need to be compared to C45000)?

HTH,
Bernie
MS Excel MVP


"Gregory Winters" wrote in message
...
Thanks, Bernie! I have only one other criterion: the sum column could
contain as many as 45,000 cells. Is there a way to alter cell reference
piece of the If Range statement to accomodate this? Thanks!

Greg

"Bernie Deitrick" wrote:

Greg,

Copy the code below, right-click the sheet tab, select "View Code" and paste the code into the
window that appears. You may want to play with the various Exit Sub conditions....

HTH,
Bernie
MS Excel MVP


Private Sub Worksheet_Calculate()
If Range("C1").Value = "" Then Exit Sub
If Range("C2").Value = "" Then Exit Sub
If Range("C1").Value = 0 Then Exit Sub
If Range("C2").Value = 0 Then Exit Sub

If Range("C1").Value = Range("C2").Value Then
MsgBox "Hey! C1 is the same as C2!"
End If
End Sub


"Gregory Winters" wrote in message
...
I already know that the standard tool that comes with Excel only works with
data entry cells, but because of the context of more complex spreadsheets,
there has to be a way to perform simple validations (which render a similar
dialog to the user) when the results of his/her work are invalid in
calculated cells?!

My task is simple: Cell C1 renders a simple sum Fx from cells A1 and B1.
Cell C2 = A2 + B2, etc. All I need to have Excel do is tell the user right
away whenever C1=C2, or in batches in the event of Copy and Paste.

Any help would be greatly appreciated!

Greg