ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiple cells for changing my spreadsheet? (https://www.excelbanter.com/excel-programming/423833-multiple-cells-changing-my-spreadsheet.html)

timmtamm

Multiple cells for changing my spreadsheet?
 
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



All times are GMT +1. The time now is 10:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com