LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Trigger Macro based on single Cell change

Per Jessen wrote:
This should do it:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = Range("Method").Address Then
If Me.Range("Method").Value = "D" Then
Rows("14:19").EntireRow.Hidden = False
Rows("51:53").EntireRow.Hidden = False
Else
Rows("51:53").EntireRow.Hidden = True
Rows("14:19").EntireRow.Hidden = True
End If
End If
End Sub

Regards,
Per

On 27 Nov., 18:16, gtslabs wrote:
Trigger Macro based on single Cell change

I have a range named "Method". it is only 1 cell and contains the Data
Validation Letters A,B,C,D and is used on the form as a dropdown list.

I want to trigger the following code based on the value (A,B,C or D).
Right now it uns every time I change any cell value in the worksheet.
Can this be done?

Private Sub Worksheet_Change(ByVal Target As Range)

If Me.Range("Method").Value = "D" Then
Rows("14:19").Select
Selection.EntireRow.Hidden = False
Rows("51:53").Select
Selection.EntireRow.Hidden = False

Else

Rows("51:53").Select
Selection.EntireRow.Hidden = True
Rows("14:19").Select
Selection.EntireRow.Hidden = True
End If
End Sub



Hi. Just a slightly different version of the same code...

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
'// Hide rows if NOT "D"
Range("14:19, 51:53").EntireRow.Hidden = _
(Me.Range("Method").Value < "D")
Application.EnableEvents = True
End Sub

= = =
Dana DeLouis


 
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
Cell Change Trigger [email protected] Excel Programming 2 March 29th 07 08:35 PM
Trigger macro when specific cell doesn't change Gail Schweitzer Excel Programming 2 March 21st 07 07:28 PM
Trigger Macro on change in cell value qwerty[_2_] Excel Programming 3 April 26th 06 05:24 AM
Cell change to trigger Macro Sören_Marodören Excel Programming 2 April 11th 06 11:09 AM
Cell value change to trigger macro (worksheet change event?) Neil Goldwasser Excel Programming 4 January 10th 06 01:55 PM


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