Multiple cells for changing my spreadsheet?

T

timmtamm

Is it possible to use various cells to affect my spreadsheet? I need to hide
various rows and change print area based on a separate cell than the current
one.

For example, if I type .84 into B20 I want it to adjust things as written
below, but if I then type in "US Formula" into cell J20 I want it to hide
rows 94 to 124 and print before that row. I tried doing this by setting up
an all new sub for the worksheet in addition to this one (using this one as a
pattern), but excel didn't like that.

Sub Worksheet_Change(ByVal Target As Range)
Dim v As Double

Set t = Target
Set r = Range("B20")
If Intersect(t, r) Is Nothing Then
Exit Sub
Else
v = Val(r.Value)
End If
Select Case v

Case 0.84
Rows("63:124").EntireRow.Hidden = True
ActiveSheet.PageSetup.PrintArea = "$A$1:$I$62"
Case Is < 0.84
Rows("63:124").EntireRow.Hidden = False
ActiveSheet.PageSetup.PrintArea = "$A$1:$I$124"
Case Is > 0.84
Rows("63:124").EntireRow.Hidden = False
ActiveSheet.PageSetup.PrintArea = "$A$1:$I$124"
End Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top