how to disable a macro by calling it from another macro

  • Thread starter Thread starter paritoshmehta
  • Start date Start date
P

paritoshmehta

Hi,

I have this sheet (reports-sheet) within a workbook and whenever i
gets activated (clicked) a macro runs to do some calculations!!!

I also have another macro which pastes data into this sheet but th
macro somehow cannot run without disabling the macro in the earlie
sheet, ........ so I was thinking if its possible to disable th
reports-sheet macro while the main marco is running and leave i
enabled otherwose???

Thank
 
Wrap your code with

Application.EnableEvents = False
'your code here
Application.EnableEvents = True
 
I don't really understand your situation, but perhaps you can
disable events to prevent the activate event procedure from
executing. E.g.,

Application.EnableEvents = False
' your code here
Application.EnableEvents = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"paritoshmehta >" <<[email protected]>
wrote in message
news:p[email protected]...
 
Hi
you may disable the application events prior to executing your code
with
Application.EnableEvents = False

After your code has been executed enable the events again with
Application.EnableEvents = True
 
Hi,

I tried the "Application.EnableEvents" method, but it gave me the erro
1004 "select method of range class failed"

let me try explaining it again:

there is this first macro(1st) which doesnot let anyone select th
cells in the area b2:c2001 and there is another macro(2nd) which want
to copy the contents in the same area and paste the values (past
special>values) in that area, but the 1st one doesnt allow .........

i hope i have explained the problem clearly now.....

thanks again for replying!!
 
Oops.... sorry... i forgot to metion this:

I have this code written which doesnt let the user to select the cell
(to prevent accidental deletion):

1st macro:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Me.Range("b2:c2001")) Is Nothing Then Exit Sub
Me.Cells(Target.Row, "D").Select

End Sub


Now the problem is that i want a macro which will just copy the b and
columns and paste the values to the same columns, the macro is preet
simple, the problem is that because of the earlier macro, i canno
select the columns.....

2nd Macro:
Sub Macro()

Range("B1:C1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Range("B1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:
_
False, Transpose:=False
End Sub


is there a way where i can turn the fist macro OFF when the secon
macro runs???

thanks for any help!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top