Hi All,
I use the below code, will be reduced to smaller level, I am just making the rows hide, if the cell value is blank.
Also, i was trying to save the file in a path, however when we click on Alt F11, it still shows this code.
I use the below code, will be reduced to smaller level, I am just making the rows hide, if the cell value is blank.
Also, i was trying to save the file in a path, however when we click on Alt F11, it still shows this code.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$6" Then
Application.EnableEvents = False
If Range("C6").Value = "" Then
Rows("11:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("11:12").Select
Selection.EntireRow.Hidden = False
End If
Range("C6").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$12" Then
Application.EnableEvents = False
If Range("C12").Value = "" Then
Rows("13:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("13:13").Select
Selection.EntireRow.Hidden = False
End If
Range("C12").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$13" Then
Application.EnableEvents = False
If Range("C13").Value = "" Then
Rows("14:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("14:14").Select
Selection.EntireRow.Hidden = False
End If
Range("C14").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$14" Then
Application.EnableEvents = False
If Range("C14").Value = "" Then
Rows("15:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("15:15").Select
Selection.EntireRow.Hidden = False
End If
Range("C15").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$15" Then
Application.EnableEvents = False
If Range("C15").Value = "" Then
Rows("16:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("16:17").Select
Selection.EntireRow.Hidden = False
End If
Range("C16").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$17" Then
Application.EnableEvents = False
If Range("C17").Value = "" Then
Rows("18:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("18:18").Select
Selection.EntireRow.Hidden = False
End If
Range("C18").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$18" Then
Application.EnableEvents = False
If Range("C18").Value = "" Then
Rows("19:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("19:19").Select
Selection.EntireRow.Hidden = False
End If
Range("C18").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$19" Then
Application.EnableEvents = False
If Range("C19").Value = "" Then
Rows("20:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("20:20").Select
Selection.EntireRow.Hidden = False
End If
Range("C19").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$20" Then
Application.EnableEvents = False
If Range("C20").Value = "" Then
Rows("21:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("21:21").Select
Selection.EntireRow.Hidden = False
End If
Range("C20").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$21" Then
Application.EnableEvents = False
If Range("C21").Value = "" Then
Rows("22:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("22:22").Select
Selection.EntireRow.Hidden = False
End If
Range("C21").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$22" Then
Application.EnableEvents = False
If Range("C22").Value = "" Then
Rows("23:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("23:24").Select
Selection.EntireRow.Hidden = False
End If
Range("C22").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$24" Then
Application.EnableEvents = False
If Range("C24").Value = "" Then
Rows("25:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("25:25").Select
Selection.EntireRow.Hidden = False
End If
Range("C24").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$25" Then
Application.EnableEvents = False
If Range("C25").Value = "" Then
Rows("26:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("26:26").Select
Selection.EntireRow.Hidden = False
End If
Range("C25").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$26" Then
Application.EnableEvents = False
If Range("C26").Value = "" Then
Rows("27:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("27:27").Select
Selection.EntireRow.Hidden = False
End If
Range("C26").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$27" Then
Application.EnableEvents = False
If Range("C27").Value = "" Then
Rows("28:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("28:28").Select
Selection.EntireRow.Hidden = False
End If
Range("C27").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$28" Then
Application.EnableEvents = False
If Range("C28").Value = "" Then
Rows("29:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("29:29").Select
Selection.EntireRow.Hidden = False
End If
Range("C28").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$29" Then
Application.EnableEvents = False
If Range("C29").Value = "" Then
Rows("30:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("30:30").Select
Selection.EntireRow.Hidden = False
End If
Range("C29").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$30" Then
Application.EnableEvents = False
If Range("C30").Value = "" Then
Rows("31:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("31:31").Select
Selection.EntireRow.Hidden = False
End If
Range("C30").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$31" Then
Application.EnableEvents = False
If Range("C31").Value = "" Then
Rows("32:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("32:32").Select
Selection.EntireRow.Hidden = False
End If
Range("C31").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$32" Then
Application.EnableEvents = False
If Range("C32").Value = "" Then
Rows("33:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("33:33").Select
Selection.EntireRow.Hidden = False
End If
Range("C32").Select
Application.EnableEvents = True
End If
If Target.Address = "$C$33" Then
Application.EnableEvents = False
If Range("C33").Value = "" Then
Rows("34:63").Select
Selection.EntireRow.Hidden = True
Else
Rows("34:63").Select
Selection.EntireRow.Hidden = False
End If
Range("C33").Select
Application.EnableEvents = True
ThisFile = Right(Range("C2").Value, 6) & " - " & Range("C5").Value & " - " & Format(Now, "mmddyyyy") & ".xls"
ActiveWorkbook.SaveAs Filename:="C:\Cash Files" & ThisFile
End If
End Sub
Last edited by a moderator: