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

Thanks Jim! It works great!
I missed your answer yesterday. Thanks for the Event tip too. I'm going to
study it.
Amy


"Jim Cone" wrote:

Events would be the word to look up not target.
You are using the Worksheet Change event.
In the sheet module at the top are two drop down boxes.
Set the left box to "Worksheet" and then look at the items displayed
in the right box. It shows all the events applicable to that sheet.
Click one and see what happens.

Remove the code from the Sheet2 module and place the following
code in the Sheet1 module...
(notice the dots in front of Rows)
'---------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$A$1" Then
With Worksheets("Sheet2")
.Rows("1:35").EntireRow.Hidden = False
If Target.Text = "Apples" Then
.Rows("10:10").EntireRow.Hidden = True
.Rows("20:20").EntireRow.Hidden = True
ElseIf Target.Text = "Pears" Then
.Rows("15:15").EntireRow.Hidden = True
.Rows("25:25").EntireRow.Hidden = True
ElseIf Target.Text = "Oranges" Then
.Rows("30:30").EntireRow.Hidden = True
.Rows("35:35").EntireRow.Hidden = True
Else
.Rows("12:12").EntireRow.Hidden = True
.Rows("16:16").EntireRow.Hidden = True
End If
End With
End If
End Sub
-----------
Jim Cone
San Francisco, USA
http://www.officeletter.com/blink/specialsort.html



"AMY Z."
wrote in message
Thanks Dave & Jim for answering my question and taking time to explain this.
It works!
Well sort of.....
Something I didn't think about, Cell A1 in Sheet2 is actually linked to Cell
A1 in Sheet1. Then it doesn't work.

I tried setting the same procedure up in Sheet1 and added a line at the
start of each IF block that says: "Sheets("Sheet2").Select". But it still
hides the rows in Sheet1.
Should I leave the procedure in Sheet2 the way it was, and somehow change
the Target.Address line to: Sheet1 "A1"?
If it is the Target.Address line, could you help with the syntax to set it
up? I can't find an example in any of my books that refers the Target.Address
for another worksheet. Or do I have to start from scratch.
Thank you again for your time. I'm excited that I have at least got the
procedure to work, except for the linkage problem.




 
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 12:42 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"