ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   MACRO HELP (https://www.excelbanter.com/excel-programming/383241-macro-help.html)

[email protected]

MACRO HELP
 
I have a macro that changes a cell value, for example it changes the
value of cell "A1", I have another macro that I have set to run in the
worksheet_change event when "A1" is changed. My problem is when I run
the first macro and it changes the value in "A1" in doesn't run the
second macro. Is there something I need to do so it will recognize the
change in "A1" and consider it as the target so my second macro will
run?

Any help would be greatly appreciated.


Tom Ogilvy

MACRO HELP
 
Does the first macro disable events?

--
Regards,
Tom Ogilvy

" wrote:

I have a macro that changes a cell value, for example it changes the
value of cell "A1", I have another macro that I have set to run in the
worksheet_change event when "A1" is changed. My problem is when I run
the first macro and it changes the value in "A1" in doesn't run the
second macro. Is there something I need to do so it will recognize the
change in "A1" and consider it as the target so my second macro will
run?

Any help would be greatly appreciated.



joel

MACRO HELP
 
One suggestion is not to use hard codes for Text cells
Declaring cell as Const. Then I simply change the const statement rather
than changing a lot of code.

" wrote:

I have a macro that changes a cell value, for example it changes the
value of cell "A1", I have another macro that I have set to run in the
worksheet_change event when "A1" is changed. My problem is when I run
the first macro and it changes the value in "A1" in doesn't run the
second macro. Is there something I need to do so it will recognize the
change in "A1" and consider it as the target so my second macro will
run?

Any help would be greatly appreciated.



davegb

MACRO HELP
 
On Feb 14, 11:17 am, Joel wrote:
One suggestion is not to use hard codes for Text cells
Declaring cell as Const. Then I simply change the const statement rather
than changing a lot of code.



" wrote:
I have a macro that changes a cell value, for example it changes the
value of cell "A1", I have another macro that I have set to run in the
worksheet_change event when "A1" is changed. My problem is when I run
the first macro and it changes the value in "A1" in doesn't run the
second macro. Is there something I need to do so it will recognize the
change in "A1" and consider it as the target so my second macro will
run?


Any help would be greatly appreciated.- Hide quoted text -


- Show quoted text -


If I remember, you can't declare a cell, since it's not an object in
the Object Model. You have to declare the range, in this case, a
single cell.


[email protected]

MACRO HELP
 
Yeah I had the code set like this

Application.EnableEvents = False
'code
'code
'code
'more code
Application.Run "MyMacro"
Application.EnableEvents = True

If I take out the EnableEvents line is works however know in my second
macro I have it creating a validation list in a cell that is offset
from the target. It works when I change the cell manually but when my
first macro changes the cell I get a runtime error '1004': Application-
defined or Object defined error. Any ideas why?


Tom Ogilvy

MACRO HELP
 
I think people would have to see all the code to suggest anything. Indicate
which line is highlighted when you get the error message. Also indicate
where the elements of the code are located - in a general module or in a
sheet module and if in a sheet module, which sheet module each is in.

I suspect your problem is in a reference - so if you qualify all your range
references with what sheet they are located on, then perhaps that will solve
the problem.

this may be true for the reference you are using in the data validation as
well.

--
Regards,
Tom Ogilvy


" wrote:

Yeah I had the code set like this

Application.EnableEvents = False
'code
'code
'code
'more code
Application.Run "MyMacro"
Application.EnableEvents = True

If I take out the EnableEvents line is works however know in my second
macro I have it creating a validation list in a cell that is offset
from the target. It works when I change the cell manually but when my
first macro changes the cell I get a runtime error '1004': Application-
defined or Object defined error. Any ideas why?




All times are GMT +1. The time now is 09:59 AM.

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