ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can I have two worksheet_change events in same worksheet? (https://www.excelbanter.com/excel-programming/396466-can-i-have-two-worksheet_change-events-same-worksheet.html)

klysell

Can I have two worksheet_change events in same worksheet?
 
Hi,

Can I have two worksheet_change procedures within the same worksheet code
window? If so, how do I differentiate between the two procedures without
there being a conflict? Upon enacting one of the worksheet_change events, I
have the message that there has been an ambiguous naming conflict in my code.

Thanks,
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557

Vergel Adriano

Can I have two worksheet_change events in same worksheet?
 
Kent,

there can only be one worksheet_change event procedure for each worksheet.


--
Hope that helps.

Vergel Adriano


"klysell" wrote:

Hi,

Can I have two worksheet_change procedures within the same worksheet code
window? If so, how do I differentiate between the two procedures without
there being a conflict? Upon enacting one of the worksheet_change events, I
have the message that there has been an ambiguous naming conflict in my code.

Thanks,
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557


Pflugs

Can I have two worksheet_change events in same worksheet?
 
You cannot have two Worksheet_Change events. Rahter, the separate task
should be place within the same procedure, and IF-THEN blocks should be used
to allow either, both, or none to run.

Pflugs

"klysell" wrote:

Hi,

Can I have two worksheet_change procedures within the same worksheet code
window? If so, how do I differentiate between the two procedures without
there being a conflict? Upon enacting one of the worksheet_change events, I
have the message that there has been an ambiguous naming conflict in my code.

Thanks,
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557


klysell

Can I have two worksheet_change events in same worksheet?
 
Is there any way to combine the two under one procedure?
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557


"Vergel Adriano" wrote:

Kent,

there can only be one worksheet_change event procedure for each worksheet.


--
Hope that helps.

Vergel Adriano


"klysell" wrote:

Hi,

Can I have two worksheet_change procedures within the same worksheet code
window? If so, how do I differentiate between the two procedures without
there being a conflict? Upon enacting one of the worksheet_change events, I
have the message that there has been an ambiguous naming conflict in my code.

Thanks,
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557


Vergel Adriano

Can I have two worksheet_change events in same worksheet?
 
You can use Select, or If statements to call a different sub procedure
depending on certain conditions.. but they have to be under just one
worksheet_change event procedure.. for example:

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address
Case "$A$1":
MsgBox "execute a sub procedure"
Case "$A$2":
MsgBox "execute a different sub procedure"
End Select
End Sub



--
Hope that helps.

Vergel Adriano


"Vergel Adriano" wrote:

Kent,

there can only be one worksheet_change event procedure for each worksheet.


--
Hope that helps.

Vergel Adriano


"klysell" wrote:

Hi,

Can I have two worksheet_change procedures within the same worksheet code
window? If so, how do I differentiate between the two procedures without
there being a conflict? Upon enacting one of the worksheet_change events, I
have the message that there has been an ambiguous naming conflict in my code.

Thanks,
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557


klysell

Can I have two worksheet_change events in same worksheet?
 
Thanks all.
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557


"Pflugs" wrote:

You cannot have two Worksheet_Change events. Rahter, the separate task
should be place within the same procedure, and IF-THEN blocks should be used
to allow either, both, or none to run.

Pflugs

"klysell" wrote:

Hi,

Can I have two worksheet_change procedures within the same worksheet code
window? If so, how do I differentiate between the two procedures without
there being a conflict? Upon enacting one of the worksheet_change events, I
have the message that there has been an ambiguous naming conflict in my code.

Thanks,
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557



All times are GMT +1. The time now is 05:30 PM.

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