Arty Choke
New Member
- Joined
- Oct 7, 2009
- Messages
- 9
I have a spreadsheet that runs a macro when a change happens within either of two named ranges. The original code is as follows:
Private Sub Worksheet_Change(ByVal Target As Range)
'Check to see that we have enabled auto macro updating
If Range("Report_Type_Auto_Run_Macros") = "ENABLED" Then
'Remember which cell I started on, so I can return there
Starting_Cell = ActiveCell.Address
'Turn off ALL events so the sub does not put the code into a loop.
Application.EnableEvents = False
'Hide and Unhide Rows - Did we change something warranting a Row Hide / Unhide update?
'**********
If Not Intersect(Target, Range("Report_Type_Row_Flags", "Report_Type_Selected")) Is Nothing Then
Call Hide_and_Unhide_Rows_and_Columns
End If
'Turn on ALL events
Application.EnableEvents = True
'Return to the cell I started on
Range(Starting_Cell).Select
End If
End Sub
I noticed that the macro was being called by changes in cells other than just those in the named ranges. I believe that I made an error in the line following "'**********". I had enclosed each of the named ranged in seperate quotes, and should have grouped them within the same quotes. I changed the line to read as follows:
If Not Intersect(Target, Range("Report_Type_Row_Flags, Report_Type_Selected")
It is no longer triggered by the wrong cells, but it also no longers reacts to cell value changes in the named range "Report_Type_Row_Flags" unless I type in a new value. It used to react any time the formulas in these cells caused any of them to change value. The other named range is a data validation list, and works fine.
How do I make the Worksheet_Change react to cell value changes caused by formulas?
Thanks!
Arty
Private Sub Worksheet_Change(ByVal Target As Range)
'Check to see that we have enabled auto macro updating
If Range("Report_Type_Auto_Run_Macros") = "ENABLED" Then
'Remember which cell I started on, so I can return there
Starting_Cell = ActiveCell.Address
'Turn off ALL events so the sub does not put the code into a loop.
Application.EnableEvents = False
'Hide and Unhide Rows - Did we change something warranting a Row Hide / Unhide update?
'**********
If Not Intersect(Target, Range("Report_Type_Row_Flags", "Report_Type_Selected")) Is Nothing Then
Call Hide_and_Unhide_Rows_and_Columns
End If
'Turn on ALL events
Application.EnableEvents = True
'Return to the cell I started on
Range(Starting_Cell).Select
End If
End Sub
I noticed that the macro was being called by changes in cells other than just those in the named ranges. I believe that I made an error in the line following "'**********". I had enclosed each of the named ranged in seperate quotes, and should have grouped them within the same quotes. I changed the line to read as follows:
If Not Intersect(Target, Range("Report_Type_Row_Flags, Report_Type_Selected")
It is no longer triggered by the wrong cells, but it also no longers reacts to cell value changes in the named range "Report_Type_Row_Flags" unless I type in a new value. It used to react any time the formulas in these cells caused any of them to change value. The other named range is a data validation list, and works fine.
How do I make the Worksheet_Change react to cell value changes caused by formulas?
Thanks!
Arty