Thread: Macro Trigger
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Stringhaussen Stringhaussen is offline
external usenet poster
 
Posts: 13
Default Macro Trigger

Hi Sam,

Thanks for your help. I'm still not getting this to work, if I type in any
other cell after I hit enter it automatically selects row 19:24 as in the
coding.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = True
If Target.Address = F18 Then
ElseIf Range("F18").Text = "No" Then
Rows("19:24").Select
Range("A19").Activate
Selection.EntireRow.Hidden = True
ElseIf Range("F18").Text = "Yes" Then
Rows("18:25").Select
Range("A19").Activate
Selection.EntireRow.Hidden = False
ElseIf Range("F18").Text = "" Then
Rows("19:24").Select
Range("A19").Activate
Selection.EntireRow.Hidden = True
End If
End Sub

Regards,

Stringhaussen

"Sam Wilson" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.address = $F$18 then

'Your code

end if

end sub

"Stringhaussen" wrote:

Hi,

I've created a spreadsheet where I want rows to hide/reveal depending on the
contents of a Cell. The code I used below works however every time I complete
another cell on the spreadsheet the macro is triggered.

Is there a way to only run the one time when you complete cell F18 and then
have it disabled until you change that cell value again?

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = True
If Range("F18").Text = "No" Then
Rows("19:24").Select
Range("A19").Activate
Selection.EntireRow.Hidden = True
Exit Sub
ElseIf Range("F18").Text = "Yes" Then
Rows("18:25").Select
Range("A19").Activate
Selection.EntireRow.Hidden = False
Exit Sub
ElseIf Range("F18").Text = "" Then
Rows("19:24").Select
Range("A19").Activate
Selection.EntireRow.Hidden = True
Exit Sub
End If
End Sub

Thanks,
Stringhaussen