#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 86
Default Auto run macro

I have an array (B6:J21) that requires a macro being run (sorting
macro) when any figure in the array is changed. How can I run this
macro "on demand"??
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Auto run macro

Include the following macro in the wroksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set r = Range("B6:J21")
If Intersect(t, r) Is Nothing Then Exit Sub
Application.EnableEvents = False
Call yoursub
Application.EnableEvents = True
End Sub


Because it is worksheet code, it is very easy to install and automatic to use:

1. right-click the tab name near the bottom of the Excel window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you have any concerns, first try it on a trial worksheet.

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu2007k


"Esradekan" wrote:

I have an array (B6:J21) that requires a macro being run (sorting
macro) when any figure in the array is changed. How can I run this
macro "on demand"??

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 86
Default Auto run macro

From what you have said or pointed me to read, I take it that the
macro will not change or "sort" if there is a change by formula. Is
that right??

I tried this, and doesnt seem to work and I suspect that is the cause.

Esra


Gary''s Student wrote:
Include the following macro in the wroksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set r = Range("B6:J21")
If Intersect(t, r) Is Nothing Then Exit Sub
Application.EnableEvents = False
Call yoursub
Application.EnableEvents = True
End Sub

Because it is worksheet code, it is very easy to install and automatic to use:

1. right-click the tab name near the bottom of the Excel window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you have any concerns, first try it on a trial worksheet.

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu2007k



"Esradekan" wrote:
I have an array (B6:J21) that requires a macro being run (sorting
macro) when any figure in the array is changed. *How can I run this
macro "on demand"??- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 915
Default Auto run macro

Esradekan wrote:
From what you have said or pointed me to read, I take it that the
macro will not change or "sort" if there is a change by formula. Is
that right??

I tried this, and doesnt seem to work and I suspect that is the cause.

Hi Esra,

I think you are correct. The Worksheet_Change event is not triggered by
a formula calculation.

See also
http://www.cpearson.com/excel/Events.aspx

Would you be able to trap a change in the precedent(s) to the formulae
instead?
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 86
Default Auto run macro

I do have a workbook where this exact thing happens, a "sort" macro is
executed on a change in the array, ,but it is someone elses work and
is password protected. I dont know what the password is. Is there a
way that I can view thw code used in that book? That may help me.

Esra




On Sep 1, 10:20*am, wrote:
Esradekan wrote:
From what you have said or pointed me to read, I take it that the
macro will not change or "sort" if there is a change by formula. *Is
that right??


I tried this, and doesnt seem to work and I suspect that is the cause.


Hi Esra,

I think you are correct. The Worksheet_Change event is not triggered by
a formula calculation.

See alsohttp://www.cpearson.com/excel/Events.aspx

Would you be able to trap a change in the precedent(s) to the formulae
instead?




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 915
Default Auto run macro

This site explains how Excel password protection works (and doesn't):

http://www.mcgimpsey.com/excel/removepwords.html

Esradekan wrote:
I do have a workbook where this exact thing happens, a "sort" macro is
executed on a change in the array, ,but it is someone elses work and
is password protected. I dont know what the password is. Is there a
way that I can view thw code used in that book? That may help me.

Esra




On Sep 1, 10:20 am, wrote:
Esradekan wrote:
From what you have said or pointed me to read, I take it that the
macro will not change or "sort" if there is a change by formula. Is
that right??
I tried this, and doesnt seem to work and I suspect that is the cause.

Hi Esra,

I think you are correct. The Worksheet_Change event is not triggered by
a formula calculation.

See alsohttp://www.cpearson.com/excel/Events.aspx

Would you be able to trap a change in the precedent(s) to the formulae
instead?


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
Sub Macro vrs Function Macro Auto Start Pat Excel Discussion (Misc queries) 7 June 6th 07 09:53 PM
Run Auto Macro only once Jim D Excel Worksheet Functions 2 May 23rd 07 11:37 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro - Auto Run Gary Excel Worksheet Functions 1 May 12th 06 08:29 PM
macro for auto sum ahemani New Users to Excel 2 July 29th 05 12:53 AM


All times are GMT +1. The time now is 11:43 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"