LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default My 1st IF-THEN-ELSE Procedure

Hi,
This is what I'm trying to do: It is in Worksheet2. I would like it to run
when cell A1 changes:

If cell A1 says Apples then hide rows 10 & 20.
If A1 says Pears then hide rows 15 & 25.
If A1 says Oranges then hide rows 30 & 35.

If A1 doesn't say any of the above then Unhide all rows (to reset) and hide
rows 12 & 16. (This is Default for all other Fruits).


This is what I wrote but it wont work. Im not getting any code errors, but
it just sits there.

If Worksheets("Sheet2").Range("A1").Text = "Apples" Then
Rows("10:10").Select
Selection.EntireRow.Hidden = True
Rows("20:20").Select
Selection.EntireRow.Hidden = True
ElseIf Worksheets("Sheet2").Range("A1").Text = "Pears" Then
Rows("15:15").Select
Selection.EntireRow.Hidden = True
Rows("25:25").Select
Selection.EntireRow.Hidden = True
ElseIf Worksheets("Sheet2").Range("A1").Text = "Oranges" Then
Rows("30:30").Select
Selection.EntireRow.Hidden = True
Rows("35:35").Select
Selection.EntireRow.Hidden = True
Else: Worksheets ("Sheet2")
Rows("1:35").Select
Selection.EntireRow.Hidden = False
Rows("12:12").Select
Selection.EntireRow.Hidden = True
Rows("16:16").Select
Selection.EntireRow.Hidden = True
End If

End Sub

Should I put this under the General section of the Sheet2 Object in the VB
editor?
This is the first procedure that Ive tried to write.
Thank for your time,
Amy

 
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
Stop a Procedure from another procedure Ayo Excel Discussion (Misc queries) 1 October 30th 08 01:42 AM
Calling a procedure in a procedure Norman Jones Excel Programming 8 August 20th 04 07:53 PM
Calling a procedure in a procedure N10 Excel Programming 2 August 18th 04 12:49 AM
Calling a procedure in a procedure Don Guillett[_4_] Excel Programming 1 August 17th 04 11:31 PM


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

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"