![]() |
VBA to hide a row in different worksheet
I need a VBA code to automatically hide or unhide a row in one sheet based
upon the value is a cell on another sheet. Example: If Sheet1, cell A1 = 0, then Sheet2, row 5 is hiden. If Sheet1, cell A1 0, then Sheet2, row 5 is visible. Suggestions? |
Answer: VBA to hide a row in different worksheet
Formula:
Formula:
|
VBA to hide a row in different worksheet
Try: will unhide if not 0 (blank or < 0)
Sub HideRow() If Worksheets("sheet1").Range("A1") = 0 Then Worksheets("sheet2").Rows(5).EntireRow.Hidden = True Else Worksheets("sheet2").Rows(5).EntireRow.Hidden = False End If End Sub "TDC" wrote: I need a VBA code to automatically hide or unhide a row in one sheet based upon the value is a cell on another sheet. Example: If Sheet1, cell A1 = 0, then Sheet2, row 5 is hiden. If Sheet1, cell A1 0, then Sheet2, row 5 is visible. Suggestions? |
VBA to hide a row in different worksheet
for the row to automatically get hidden a Worksheet change Event need to be
added into the code. Install as follows 1) right click tab on bottom of worksheet labeled Sheet1. 2) Select view Code 3) Copy subroutine below and paste into VBA Code window. Sub Worksheet_Change(ByVal Target As Range) If (Target.Row = 1) And (Target.Column = 1) And _ (Target = 0) Then Worksheets("sheet2").Rows(5).EntireRow.Hidden = True Else Worksheets("sheet2").Rows(5).EntireRow.Hidden = False End If End Sub "TDC" wrote: I need a VBA code to automatically hide or unhide a row in one sheet based upon the value is a cell on another sheet. Example: If Sheet1, cell A1 = 0, then Sheet2, row 5 is hiden. If Sheet1, cell A1 0, then Sheet2, row 5 is visible. Suggestions? |
All times are GMT +1. The time now is 11:30 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com