-
Stop code without ESC key
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?
[vba]
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
[/vba]
WOW! it's great to be back on the board. Took a vacation from Excel for a while.
Thanks
-
the selection_change is triggered by the procedure itself everytime you paste.
-
Precede your code with
[vba]
On Error GoTo ws_exit:
Application.EnableEvents = False
[/vba]
and afterwards add
[vba]
ws_exit:
Application.EnableEvents = True
[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules