Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default Macro Problem

I have a code that creates a quote by moving sheets to a new file. When I
step through the macro, for some reason it is calling upon a
worksheet_selectionchange and causing my virtual memory to go through the
roof. How do I prevent my macro from automatically calling about the
worksheet_selectionchange that I have created. Here is the code that is
causing it to goto the worksheet_selectionchange, along with the code for the
Worksheet_selectionchange. My worksheet_selectionchange is under my
"Agreement" Tab and that is when it gets called upon by the macro. Hope this
makes sense. Any help is appreciated.

AWB.Activate
Sheets("Agreement").Select
Sheets("Agreement").Copy Befo=Workbooks("Email Template
Macro3l.xls").Sheets _
(3)
Cells.Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Cells.Select

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row = 52 Then
With Worksheets("Agreement")
promptdialog.Show
End With
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default Macro Problem

Brad

You can use Application.EnableEvents = False at the start of your sub and
then set it to True at the end. That will prevent the selectionchange event
from firing when that particular code is run.

What you might consider, though, is revising your code so that nothing is
selected.

ActiveWorkbook.Sheets("Agreement").Copy Befo=etc...
With Activesheet
.Cells.Copy
.Range("A1").PasteSpecial etc..
End With
Application.CutCopyMode = False

By not selecting in your code, the event won't fire.

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

Brad wrote:
I have a code that creates a quote by moving sheets to a new file.
When I step through the macro, for some reason it is calling upon a
worksheet_selectionchange and causing my virtual memory to go through
the roof. How do I prevent my macro from automatically calling about
the worksheet_selectionchange that I have created. Here is the code
that is causing it to goto the worksheet_selectionchange, along with
the code for the Worksheet_selectionchange. My
worksheet_selectionchange is under my "Agreement" Tab and that is
when it gets called upon by the macro. Hope this makes sense. Any
help is appreciated.

AWB.Activate
Sheets("Agreement").Select
Sheets("Agreement").Copy Befo=Workbooks("Email Template
Macro3l.xls").Sheets _
(3)
Cells.Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Cells.Select

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row = 52 Then
With Worksheets("Agreement")
promptdialog.Show
End With
End If
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default Macro Problem

Dick, thanks for the help, this has solved my problem. My next goal is to
clean up my code. Thanks again!!!!

"Dick Kusleika" wrote:

Brad

You can use Application.EnableEvents = False at the start of your sub and
then set it to True at the end. That will prevent the selectionchange event
from firing when that particular code is run.

What you might consider, though, is revising your code so that nothing is
selected.

ActiveWorkbook.Sheets("Agreement").Copy Befo=etc...
With Activesheet
.Cells.Copy
.Range("A1").PasteSpecial etc..
End With
Application.CutCopyMode = False

By not selecting in your code, the event won't fire.

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

Brad wrote:
I have a code that creates a quote by moving sheets to a new file.
When I step through the macro, for some reason it is calling upon a
worksheet_selectionchange and causing my virtual memory to go through
the roof. How do I prevent my macro from automatically calling about
the worksheet_selectionchange that I have created. Here is the code
that is causing it to goto the worksheet_selectionchange, along with
the code for the Worksheet_selectionchange. My
worksheet_selectionchange is under my "Agreement" Tab and that is
when it gets called upon by the macro. Hope this makes sense. Any
help is appreciated.

AWB.Activate
Sheets("Agreement").Select
Sheets("Agreement").Copy Befo=Workbooks("Email Template
Macro3l.xls").Sheets _
(3)
Cells.Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Cells.Select

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row = 52 Then
With Worksheets("Agreement")
promptdialog.Show
End With
End If
End Sub




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
Macro Problem DiscipleTom New Users to Excel 4 March 28th 10 01:30 PM
Macro Problem Kumar Excel Discussion (Misc queries) 1 April 29th 09 09:51 AM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
macro problem TommyBoy Excel Programming 6 August 14th 04 02:20 AM


All times are GMT +1. The time now is 06:45 PM.

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

About Us

"It's about Microsoft Excel"