ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   AutoRun Excel Macros (https://www.excelbanter.com/excel-programming/330210-autorun-excel-macros.html)

jd

AutoRun Excel Macros
 
Is there any way to automatically run a macro in excel based on the value of
a cell in that workbook? i.e. the value changes from 0 to 1 = run macro.
Anyone have a copy of code that does this? Using VBA and don't have full
blown VB - thanks!!!!

Ron de Bruin

AutoRun Excel Macros
 
Hi JD

You can use the change event
http://www.cpearson.com/excel/events.htm

Here is a example of the change event that run a macro
http://www.rondebruin.nl/mail/change.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl



--
Regards Ron de Bruin
http://www.rondebruin.nl



"JD" wrote in message ...
Is there any way to automatically run a macro in excel based on the value of
a cell in that workbook? i.e. the value changes from 0 to 1 = run macro.
Anyone have a copy of code that does this? Using VBA and don't have full
blown VB - thanks!!!!




Tom Ogilvy

AutoRun Excel Macros
 
How is the value going to change?

If by editing manually, can we assume that if the cell is edited, the macro
should run. (if it had a value of 2 and it still had a value of 2 after
editing, should the macro run?).

--
Regards,
Tom Ogilvy

"JD" wrote in message
...
Is there any way to automatically run a macro in excel based on the value

of
a cell in that workbook? i.e. the value changes from 0 to 1 = run macro.
Anyone have a copy of code that does this? Using VBA and don't have full
blown VB - thanks!!!!




jd

AutoRun Excel Macros
 
Tom,
Thanks for the reply. The value is updated every second using the built in
database query tools. The database is MS SQL - if that has any bearing.
Basically this discrete value is originates in a controller for a production
line and should drive a macro that pulls in data from three different
databases and then prints a report. All automatic - thus the dilemma. The
macro and database connectivity all works and I can manually run the macro to
generate the report and print - just need this last piece. Any ideas?

"Tom Ogilvy" wrote:

How is the value going to change?

If by editing manually, can we assume that if the cell is edited, the macro
should run. (if it had a value of 2 and it still had a value of 2 after
editing, should the macro run?).

--
Regards,
Tom Ogilvy

"JD" wrote in message
...
Is there any way to automatically run a macro in excel based on the value

of
a cell in that workbook? i.e. the value changes from 0 to 1 = run macro.
Anyone have a copy of code that does this? Using VBA and don't have full
blown VB - thanks!!!!





jd

AutoRun Excel Macros
 
Ron,
You're a genius!!!!! Works like a charm - I'll test it out on the full
production system in the morning, but, no doubt will work fine. Many
thanks!!!

"Ron de Bruin" wrote:

Hi JD

You can use the change event
http://www.cpearson.com/excel/events.htm

Here is a example of the change event that run a macro
http://www.rondebruin.nl/mail/change.htm

--
Regards Ron de Bruin
http://www.rondebruin.nl



--
Regards Ron de Bruin
http://www.rondebruin.nl



"JD" wrote in message ...
Is there any way to automatically run a macro in excel based on the value of
a cell in that workbook? i.e. the value changes from 0 to 1 = run macro.
Anyone have a copy of code that does this? Using VBA and don't have full
blown VB - thanks!!!!





Tom Ogilvy

AutoRun Excel Macros
 
I set up msquery to update every minute from an Access database and this
fired the change event. It is unclear what is updating every second - the
MS SQL database or Excel. If it is Excel, then you could use the change
event as Ron has pointed out. I doubt you need to print something every
second, particularly if you are updating from 3 different databases, but
perhaps you can cobble something together from the change event.
(retrieving data and printing a report would probably take longer than a
second, so you might have to lengthen you time between queries. )

for an overview of Events, see Chip Pearson's site:

http://www.cpeason.com/excel/events.htm

--
Regards,
Tom Ogilvy

"JD" wrote in message
...
Tom,
Thanks for the reply. The value is updated every second using the built

in
database query tools. The database is MS SQL - if that has any bearing.
Basically this discrete value is originates in a controller for a

production
line and should drive a macro that pulls in data from three different
databases and then prints a report. All automatic - thus the dilemma.

The
macro and database connectivity all works and I can manually run the macro

to
generate the report and print - just need this last piece. Any ideas?

"Tom Ogilvy" wrote:

How is the value going to change?

If by editing manually, can we assume that if the cell is edited, the

macro
should run. (if it had a value of 2 and it still had a value of 2 after
editing, should the macro run?).

--
Regards,
Tom Ogilvy

"JD" wrote in message
...
Is there any way to automatically run a macro in excel based on the

value
of
a cell in that workbook? i.e. the value changes from 0 to 1 = run

macro.
Anyone have a copy of code that does this? Using VBA and don't have

full
blown VB - thanks!!!!








All times are GMT +1. The time now is 02:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com