Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Worksheet Change Event Help Needed

Status
Not open for further replies.

ninja1980

Technical User
Sep 5, 2008
20
GB
Hi

I’m trying to produce a spreadsheet to hide a number of different rows depending upon the value of a particular cell.

I’ve tried to use worksheet related events but I just can’t get it to work.

Here is the code

**************************************************

Private Sub worksheet_change(ByVal Target As Range)

Dim myrange As Range

Set myrange = ActiveCell

Application.ScreenUpdating = False

If Target.Address = Range("Type_Select") Then

Select Case Range("Type_Select").Value

Case ""

Case "Type 1"

Rows("26:128").Select
Selection.EntireRow.Hidden = False
Rows("26:52").Select
Selection.EntireRow.Hidden = True

Case "Type 2"

Rows("26:128").Select
Selection.EntireRow.Hidden = False
Rows("53:70").Select
Selection.EntireRow.Hidden = True

Case "Type 3"

Rows("26:128").Select
Selection.EntireRow.Hidden = False
Rows("71:98").Select
Selection.EntireRow.Hidden = True

Case "Type 4"

Rows("26:128").Select
Selection.EntireRow.Hidden = False
Rows("99:128").Select
Selection.EntireRow.Hidden = True

End Select

Else

End If

myrange.Select

Application.ScreenUpdating = True

End Sub
 
If Target.Address = Range("Type_Select")
I highly doubt that the above has a chance to be true.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The range "Type_Select" is the name I've given to the cell I wish to monitor the change in.

What have I done wrong to stop this working as intended???

Thanks

 



If Target.Address = Range("Type_Select")

A range is not a range address!

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
I'd replace this:
If Target.Address = Range("Type_Select") Then
with this:
If Not Intersect(Target, Range("Type_Select")) Is Nothing Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That’s for your help PHV.

Sorry if some people find silly mistakes irritating......but we all have to start somewhere
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top