View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Macro looping endlessly

As listed, your code won't go into an endless loop, so there must be
something else going on.

Is your code within a Worksheet_Change() event macro? If so, clearing
the contents fires the Worksheet_Change() event (though the loop
shouldn't be endless - you'll eventually run out of stack space)

How is myCell determined? Do you have code that checks whether myCell is
empty?

BTW- Since you only use the .Delete method with the .Validation object,
you can replace your With .Validation...End With structure with

.Validation.Delete



In article ,
"Sandy" wrote:

Hi

The following resets the cell interior to Dark Blue - which is fine

If myCell.Value = "Hit" Then
With myCell.Offset(1).Resize(3, 1)
.Interior.ColorIndex = 11
With .Validation
.Delete
End With
End With
End If

However I need to clear the contents of the cells too - if I do this

If myCell.Value = "Hit" Then
With myCell.Offset(1).Resize(3, 1)
.Interior.ColorIndex = 11
.ClearContents
With .Validation
.Delete
End With
End With
End If

it goes into an endless loop. Any suggestions

Sandy