PDA

View Full Version : Stop code without ESC key



viper
02-22-2006, 11:04 AM
I'm using this code to copy and paste some data. I've got 11 different areas to copy and paste based on the cell value of B7. I tried a Select Case but unsuccessful so I've turned to "IF". My problem now is the code doesn't stop copying and pasting unless I hit the ESC button. I have put this code in the Change event of the worksheet, I believe it happened in the Selection_Change event as well. Any clues as to why?

If Sheet1.Cells(7, 2).Value = "Bear Creek Valley GC" Then

Range("B41:J42").Copy
Range("B12:J13").PasteSpecial (xlPasteAll)
Range("L41:t42").Copy
Range("L12:t13").PasteSpecial (xlPasteAll)
Exit Sub

End If


WOW! it's great to be back on the board. Took a vacation from Excel for a while.


Thanks

ALe
02-22-2006, 11:26 AM
the selection_change is triggered by the procedure itself everytime you paste.

Bob Phillips
02-22-2006, 11:27 AM
Precede your code with



On Error GoTo ws_exit:
Application.EnableEvents = False


and afterwards add



ws_exit:
Application.EnableEvents = True