Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Hello all, does anyone know if there is a way to create a function to
Automatically Hide a Row based on a formula In thise case if a Cell in a row (a1 for arguements sake) = 0 It would help me tidy up a work book if I could do this. Thanks Andy |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Andrew,
You could monitor A1 with code and if it is set to a value you want then hide rows: Right click the worksheet tab - view code and paste this in. Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub If Target.Address = "$A$1" Then If Target.Value = 0 Then Rows(4).Select '< Change to suit Selection.EntireRow.Hidden = True End If End If End Sub If A1 is set to zero it hides row 4 but you can change the ranges and values to suit. Mike "Andrew Duncan" wrote: Hello all, does anyone know if there is a way to create a function to Automatically Hide a Row based on a formula In thise case if a Cell in a row (a1 for arguements sake) = 0 It would help me tidy up a work book if I could do this. Thanks Andy |
#3
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Thanks Mike,
And if I wanted to monitor rows from 1 to 250 and on the same basis hide any rows that are empty Would the following work: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub If Target.Address = "$A1:$A250" Then If Target.Value = 0 Then Rows(4).Select '< Change to suit Selection.EntireRow.Hidden = True End If End If End Sub Would the usual 'Hide' and 'UnHide' (right clicking ) also work or would that now be disabled ? Andy "Mike H" wrote in message ... Andrew, You could monitor A1 with code and if it is set to a value you want then hide rows: Right click the worksheet tab - view code and paste this in. Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub If Target.Address = "$A$1" Then If Target.Value = 0 Then Rows(4).Select '< Change to suit Selection.EntireRow.Hidden = True End If End If End Sub If A1 is set to zero it hides row 4 but you can change the ranges and values to suit. Mike "Andrew Duncan" wrote: Hello all, does anyone know if there is a way to create a function to Automatically Hide a Row based on a formula In thise case if a Cell in a row (a1 for arguements sake) = 0 It would help me tidy up a work book if I could do this. Thanks Andy |
#4
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
No effect on any other worksheet functionality.
Mike "Andrew Duncan" wrote: Thanks Mike, And if I wanted to monitor rows from 1 to 250 and on the same basis hide any rows that are empty Would the following work: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub If Target.Address = "$A1:$A250" Then If Target.Value = 0 Then Rows(4).Select '< Change to suit Selection.EntireRow.Hidden = True End If End If End Sub Would the usual 'Hide' and 'UnHide' (right clicking ) also work or would that now be disabled ? Andy "Mike H" wrote in message ... Andrew, You could monitor A1 with code and if it is set to a value you want then hide rows: Right click the worksheet tab - view code and paste this in. Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub If Target.Address = "$A$1" Then If Target.Value = 0 Then Rows(4).Select '< Change to suit Selection.EntireRow.Hidden = True End If End If End Sub If A1 is set to zero it hides row 4 but you can change the ranges and values to suit. Mike "Andrew Duncan" wrote: Hello all, does anyone know if there is a way to create a function to Automatically Hide a Row based on a formula In thise case if a Cell in a row (a1 for arguements sake) = 0 It would help me tidy up a work book if I could do this. Thanks Andy |
#5
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Sorry I missed your question. No that wont work, to monitor a range of cells
try:- Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("A1:A100")) _ Is Nothing Then Exit Sub If Target.Value = 0 Then Rows(4).Select '< Change to suit Selection.EntireRow.Hidden = True End If End Sub "Andrew Duncan" wrote: Thanks Mike, And if I wanted to monitor rows from 1 to 250 and on the same basis hide any rows that are empty Would the following work: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub If Target.Address = "$A1:$A250" Then If Target.Value = 0 Then Rows(4).Select '< Change to suit Selection.EntireRow.Hidden = True End If End If End Sub Would the usual 'Hide' and 'UnHide' (right clicking ) also work or would that now be disabled ? Andy "Mike H" wrote in message ... Andrew, You could monitor A1 with code and if it is set to a value you want then hide rows: Right click the worksheet tab - view code and paste this in. Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub If Target.Address = "$A$1" Then If Target.Value = 0 Then Rows(4).Select '< Change to suit Selection.EntireRow.Hidden = True End If End If End Sub If A1 is set to zero it hides row 4 but you can change the ranges and values to suit. Mike "Andrew Duncan" wrote: Hello all, does anyone know if there is a way to create a function to Automatically Hide a Row based on a formula In thise case if a Cell in a row (a1 for arguements sake) = 0 It would help me tidy up a work book if I could do this. Thanks Andy |
#6
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Mike,
Thanks for your patience. I have a spreadsheet with 507 rows in it. At various times when accessed other worksheets may or may not of inputted data in to some or all of those rows. i.e. row A 6 clive 7 0 8 apple 9 pear 10 0 11 0 12 0 13 kart 14 bike 15 0 Rather than manually hidding or unhiding the rows with no data in column A of the Rows can we create the code to review rows 6 through 507 and hide any that have Zero in the A column ? Andy "Mike H" wrote in message ... Sorry I missed your question. No that wont work, to monitor a range of cells try:- Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("A1:A100")) _ Is Nothing Then Exit Sub If Target.Value = 0 Then Rows(4).Select '< Change to suit Selection.EntireRow.Hidden = True End If End Sub "Andrew Duncan" wrote: Thanks Mike, And if I wanted to monitor rows from 1 to 250 and on the same basis hide any rows that are empty Would the following work: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub If Target.Address = "$A1:$A250" Then If Target.Value = 0 Then Rows(4).Select '< Change to suit Selection.EntireRow.Hidden = True End If End If End Sub Would the usual 'Hide' and 'UnHide' (right clicking ) also work or would that now be disabled ? Andy "Mike H" wrote in message ... Andrew, You could monitor A1 with code and if it is set to a value you want then hide rows: Right click the worksheet tab - view code and paste this in. Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub If Target.Address = "$A$1" Then If Target.Value = 0 Then Rows(4).Select '< Change to suit Selection.EntireRow.Hidden = True End If End If End Sub If A1 is set to zero it hides row 4 but you can change the ranges and values to suit. Mike "Andrew Duncan" wrote: Hello all, does anyone know if there is a way to create a function to Automatically Hide a Row based on a formula In thise case if a Cell in a row (a1 for arguements sake) = 0 It would help me tidy up a work book if I could do this. Thanks Andy |
#7
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Andrew,
Does this work? Sub marine() For x = 507 To 1 Step -1 Cells(x, 1).Select If ActiveCell.Value < "" And ActiveCell.Value = 0 Then Selection.EntireRow.Hidden = True End If Next End Sub Mike "Andrew Duncan" wrote: Mike, Thanks for your patience. I have a spreadsheet with 507 rows in it. At various times when accessed other worksheets may or may not of inputted data in to some or all of those rows. i.e. row A 6 clive 7 0 8 apple 9 pear 10 0 11 0 12 0 13 kart 14 bike 15 0 Rather than manually hidding or unhiding the rows with no data in column A of the Rows can we create the code to review rows 6 through 507 and hide any that have Zero in the A column ? Andy "Mike H" wrote in message ... Sorry I missed your question. No that wont work, to monitor a range of cells try:- Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("A1:A100")) _ Is Nothing Then Exit Sub If Target.Value = 0 Then Rows(4).Select '< Change to suit Selection.EntireRow.Hidden = True End If End Sub "Andrew Duncan" wrote: Thanks Mike, And if I wanted to monitor rows from 1 to 250 and on the same basis hide any rows that are empty Would the following work: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub If Target.Address = "$A1:$A250" Then If Target.Value = 0 Then Rows(4).Select '< Change to suit Selection.EntireRow.Hidden = True End If End If End Sub Would the usual 'Hide' and 'UnHide' (right clicking ) also work or would that now be disabled ? Andy "Mike H" wrote in message ... Andrew, You could monitor A1 with code and if it is set to a value you want then hide rows: Right click the worksheet tab - view code and paste this in. Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub If Target.Address = "$A$1" Then If Target.Value = 0 Then Rows(4).Select '< Change to suit Selection.EntireRow.Hidden = True End If End If End Sub If A1 is set to zero it hides row 4 but you can change the ranges and values to suit. Mike "Andrew Duncan" wrote: Hello all, does anyone know if there is a way to create a function to Automatically Hide a Row based on a formula In thise case if a Cell in a row (a1 for arguements sake) = 0 It would help me tidy up a work book if I could do this. Thanks Andy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
hide/unhide | Excel Discussion (Misc queries) | |||
Hide Unhide | Excel Discussion (Misc queries) | |||
Hide/unhide | Excel Worksheet Functions | |||
Exce Hide / Unhide function | Excel Worksheet Functions | |||
Hide and unhide | Excel Discussion (Misc queries) |