Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
PFS PFS is offline
external usenet poster
 
Posts: 8
Default Why is this looping

Hi All,

I am trying to copy some values within a sheet as I deactivate it.
When I leave the sheet, it seems to get stuck in a constant loop.

Can anybody tell me what the problem might be?

Private Sub Worksheet_Deactivate()

Range("BM5:BM44").Copy
Range("D96").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=True

Range("BM48:BM87").Copy
Range("D95").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=True

Application.CutCopyMode = False

End Sub

cheers
Paul

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Why is this looping

I'd try putting

Application.enableevents = FALSE at the beginning and
Application.enableevents = TRUE at the end.

HTH,
Barb Reinhardt



"PFS" wrote:

Hi All,

I am trying to copy some values within a sheet as I deactivate it.
When I leave the sheet, it seems to get stuck in a constant loop.

Can anybody tell me what the problem might be?

Private Sub Worksheet_Deactivate()

Range("BM5:BM44").Copy
Range("D96").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=True

Range("BM48:BM87").Copy
Range("D95").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=True

Application.CutCopyMode = False

End Sub

cheers
Paul


  #3   Report Post  
Posted to microsoft.public.excel.programming
PFS PFS is offline
external usenet poster
 
Posts: 8
Default Why is this looping

thanks that worked!!!

but in my never ending quest to learn more, why?

cheers
Paul

Barb Reinhardt wrote:
I'd try putting

Application.enableevents = FALSE at the beginning and
Application.enableevents = TRUE at the end.

HTH,
Barb Reinhardt



"PFS" wrote:

Hi All,

I am trying to copy some values within a sheet as I deactivate it.
When I leave the sheet, it seems to get stuck in a constant loop.

Can anybody tell me what the problem might be?

Private Sub Worksheet_Deactivate()

Range("BM5:BM44").Copy
Range("D96").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=True

Range("BM48:BM87").Copy
Range("D95").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=True

Application.CutCopyMode = False

End Sub

cheers
Paul



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Why is this looping

but in my never ending quest to learn more, why?

The PasteSpecial operation causes the sheet to be activated. You can see
this if you add an Activate event procedure for the same sheet:

Private Sub Worksheet_Activate()
Debug.Print "Activate"
End Sub

The sheet is activated on the PasteSpecial and then deactivated again, which
causes the Deactivate event to run, and so on and so on. If you are not
copying formulas, you could use

Range("BM5:BM44").Copy Destination:=Range("D96")

rather than PasteSpecial. This code does not cause an Activate event.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"PFS" wrote in message
ups.com...
thanks that worked!!!

but in my never ending quest to learn more, why?

cheers
Paul

Barb Reinhardt wrote:
I'd try putting

Application.enableevents = FALSE at the beginning and
Application.enableevents = TRUE at the end.

HTH,
Barb Reinhardt



"PFS" wrote:

Hi All,

I am trying to copy some values within a sheet as I deactivate it.
When I leave the sheet, it seems to get stuck in a constant loop.

Can anybody tell me what the problem might be?

Private Sub Worksheet_Deactivate()

Range("BM5:BM44").Copy
Range("D96").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=True

Range("BM48:BM87").Copy
Range("D95").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=True

Application.CutCopyMode = False

End Sub

cheers
Paul




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping David T Excel Discussion (Misc queries) 2 August 30th 06 10:51 PM
Looping anderssweden Excel Programming 1 June 14th 06 03:00 PM
Looping Baffee Excel Programming 4 May 25th 06 06:57 PM
Looping Buffyslay Excel Programming 1 February 1st 06 05:57 PM
Looping Steve Excel Programming 2 September 9th 05 12:45 PM


All times are GMT +1. The time now is 02:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"