ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   if statement (https://www.excelbanter.com/excel-programming/395736-if-statement.html)

hshayhorn

if statement
 
I would like help writing some code that would run the code below if the
value of cell a5 is the word "Fixed".

Rows("5:13").Select
Selection.EntireRow.Hidden = True



George Nicholson

if statement
 
Private Sub Worksheet_Change(ByVal Target As Range)
' Target = the cell/range just changed.

If Target.Address = "$A$5" Then
Select Case UCase(Target)
Case "FIXED"
ActiveSheet.Rows("6:10").EntireRow.Hidden = True
Case "BROKEN"
ActiveSheet.Rows("11:15").EntireRow.Hidden = True
Case "REPAIR"
ActiveSheet.Rows("16:20").EntireRow.Hidden = True
Case "RESTORE"
ActiveSheet.UsedRange.Rows.EntireRow.Hidden = False
Case Else
'Do nothing
End Select
End If
End Sub

HTH,


"hshayhorn" wrote in message
...
That worked great. I'd like to add one more thing to the mix if I could. I
need this code to run as the user tabs off the A5 cell. so basically
they'll
enter a value in A5. Then when they go to the next entry cell the code
runs
and the other rows are hidden if the value is fixed. Then, I'd also like
to
add two more If to this statement. so, If A5=fixed run this code or if
A5=Broken run that code or if A5=repair then run the other code... All of
the
code by the way hides rows it just all hides different rows based on the
vales. So, can I use an ElseIF statement?

"JLGWhiz" wrote:

Sub hahaMacro()
If LCase(ActiveSheet.Range("A5").Value) = "fixed" Then
Rows("5:13").Select
Selection.EntireRow.Hidden = True
End If
End Sub


"hshayhorn" wrote:

I would like help writing some code that would run the code below if
the
value of cell a5 is the word "Fixed".

Rows("5:13").Select
Selection.EntireRow.Hidden = True






All times are GMT +1. The time now is 07:41 PM.

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