Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Al
 
Posts: n/a
Default if cell = 0 then hide the row?

My spreadsheet is a list of names and hours and charges, but if name X, say
D14, has zero hours, say F14 = 0, then I do not need the row - otherwise my
spreadsheet will have so many unused rows - and so want to hide it.

To complicate matters, my spreadsheet has titles, etc, and clearly such a
row has no value for hours in any cell, and these rows are not to be hidden.

I see something that only conisders the "data rows" and hides them if the
hours cell, F14, is zero.

Allan

  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default if cell = 0 then hide the row?

Here is one way which assumes headings in rows 1 and 2. Just chan ge the F3
to the first real data row.


Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "F3:F88536"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value = 0 Then
.EntireRow.Hidden = True
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Al" wrote in message
...
My spreadsheet is a list of names and hours and charges, but if name X,

say
D14, has zero hours, say F14 = 0, then I do not need the row - otherwise

my
spreadsheet will have so many unused rows - and so want to hide it.

To complicate matters, my spreadsheet has titles, etc, and clearly such a
row has no value for hours in any cell, and these rows are not to be

hidden.

I see something that only conisders the "data rows" and hides them if the
hours cell, F14, is zero.

Allan



  #3   Report Post  
Posted to microsoft.public.excel.misc
Pete
 
Posts: n/a
Default if cell = 0 then hide the row?

Al,

If you don't want to do it with a macro, you can achieve this using a
filter. In a column that you don't use (say column M), enter the
formula = F3 in cell M3 and copy down to cover your rows of data.
Highlight this column and select Data | Filter | Autofilter. Then
select Custom... on the pull-down list and specify "Not Equal to" and
"0" (i.e. zero) in the panels. All your rows with zero in column F will
be hidden.

Pete

  #4   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default if cell = 0 then hide the row?

Typo, should be

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "F3:F66536"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value = 0 Then
.EntireRow.Hidden = True
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Bob Phillips" wrote in message
...
Here is one way which assumes headings in rows 1 and 2. Just chan ge the

F3
to the first real data row.


Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "F3:F88536"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value = 0 Then
.EntireRow.Hidden = True
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Al" wrote in message
...
My spreadsheet is a list of names and hours and charges, but if name X,

say
D14, has zero hours, say F14 = 0, then I do not need the row -

otherwise
my
spreadsheet will have so many unused rows - and so want to hide it.

To complicate matters, my spreadsheet has titles, etc, and clearly such

a
row has no value for hours in any cell, and these rows are not to be

hidden.

I see something that only conisders the "data rows" and hides them if

the
hours cell, F14, is zero.

Allan





  #5   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default if cell = 0 then hide the row?

Problem with that is it needs to be repeated every time a value is changed
to 0, it is not event driven.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Pete" wrote in message
ups.com...
Al,

If you don't want to do it with a macro, you can achieve this using a
filter. In a column that you don't use (say column M), enter the
formula = F3 in cell M3 and copy down to cover your rows of data.
Highlight this column and select Data | Filter | Autofilter. Then
select Custom... on the pull-down list and specify "Not Equal to" and
"0" (i.e. zero) in the panels. All your rows with zero in column F will
be hidden.

Pete





  #6   Report Post  
Posted to microsoft.public.excel.misc
Al
 
Posts: n/a
Default if cell = 0 then hide the row?

Bob, Pete,

Thanks for your replies...allow me to digest your advise then I'll get back
to you with my results! One comment, I have now though, is that my "titles"
do not only apprear in say rows 1 & 2. I have many "categories" of personnel,
thus rows 17& 18 might be a header for "management", rows 34&35, for "sales
reps", rows 51&52 for "mechanics" etc etc. Does this have a consequence on
your replies?

"Bob Phillips" wrote:

Typo, should be

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "F3:F66536"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value = 0 Then
.EntireRow.Hidden = True
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Bob Phillips" wrote in message
...
Here is one way which assumes headings in rows 1 and 2. Just chan ge the

F3
to the first real data row.


Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "F3:F88536"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value = 0 Then
.EntireRow.Hidden = True
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Al" wrote in message
...
My spreadsheet is a list of names and hours and charges, but if name X,

say
D14, has zero hours, say F14 = 0, then I do not need the row -

otherwise
my
spreadsheet will have so many unused rows - and so want to hide it.

To complicate matters, my spreadsheet has titles, etc, and clearly such

a
row has no value for hours in any cell, and these rows are not to be

hidden.

I see something that only conisders the "data rows" and hides them if

the
hours cell, F14, is zero.

Allan






  #7   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default if cell = 0 then hide the row?

Then you need some type of indicator, such as a cell value, that can be
tested to see if it is a heading row.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Al" wrote in message
...
Bob, Pete,

Thanks for your replies...allow me to digest your advise then I'll get

back
to you with my results! One comment, I have now though, is that my

"titles"
do not only apprear in say rows 1 & 2. I have many "categories" of

personnel,
thus rows 17& 18 might be a header for "management", rows 34&35, for

"sales
reps", rows 51&52 for "mechanics" etc etc. Does this have a consequence

on
your replies?

"Bob Phillips" wrote:

Typo, should be

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "F3:F66536"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value = 0 Then
.EntireRow.Hidden = True
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Bob Phillips" wrote in message
...
Here is one way which assumes headings in rows 1 and 2. Just chan ge

the
F3
to the first real data row.


Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "F3:F88536"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value = 0 Then
.EntireRow.Hidden = True
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Al" wrote in message
...
My spreadsheet is a list of names and hours and charges, but if name

X,
say
D14, has zero hours, say F14 = 0, then I do not need the row -

otherwise
my
spreadsheet will have so many unused rows - and so want to hide it.

To complicate matters, my spreadsheet has titles, etc, and clearly

such
a
row has no value for hours in any cell, and these rows are not to be
hidden.

I see something that only conisders the "data rows" and hides them

if
the
hours cell, F14, is zero.

Allan








  #8   Report Post  
Posted to microsoft.public.excel.misc
Pete
 
Posts: n/a
Default if cell = 0 then hide the row?

If you want to try it my way then you will need to delete the formula
from the rows which are headings so that the cells are blank rather
than zero.

Pete

  #9   Report Post  
Posted to microsoft.public.excel.misc
Al
 
Posts: n/a
Default if cell = 0 then hide the row?

OK..now I'm off to see if I can get this to work. Thanks for all advice to
date!

"Bob Phillips" wrote:

Then you need some type of indicator, such as a cell value, that can be
tested to see if it is a heading row.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Al" wrote in message
...
Bob, Pete,

Thanks for your replies...allow me to digest your advise then I'll get

back
to you with my results! One comment, I have now though, is that my

"titles"
do not only apprear in say rows 1 & 2. I have many "categories" of

personnel,
thus rows 17& 18 might be a header for "management", rows 34&35, for

"sales
reps", rows 51&52 for "mechanics" etc etc. Does this have a consequence

on
your replies?

"Bob Phillips" wrote:

Typo, should be

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "F3:F66536"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value = 0 Then
.EntireRow.Hidden = True
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Bob Phillips" wrote in message
...
Here is one way which assumes headings in rows 1 and 2. Just chan ge

the
F3
to the first real data row.


Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "F3:F88536"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value = 0 Then
.EntireRow.Hidden = True
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Al" wrote in message
...
My spreadsheet is a list of names and hours and charges, but if name

X,
say
D14, has zero hours, say F14 = 0, then I do not need the row -
otherwise
my
spreadsheet will have so many unused rows - and so want to hide it.

To complicate matters, my spreadsheet has titles, etc, and clearly

such
a
row has no value for hours in any cell, and these rows are not to be
hidden.

I see something that only conisders the "data rows" and hides them

if
the
hours cell, F14, is zero.

Allan









  #10   Report Post  
Posted to microsoft.public.excel.misc
Al
 
Posts: n/a
Default if cell = 0 then hide the row?

OK..now I'm off to see if I can get this to work. Thanks for all advice to
date!

"Pete" wrote:

If you want to try it my way then you will need to delete the formula
from the rows which are headings so that the cells are blank rather
than zero.

Pete


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Instead of a negative number, I'd like to show zero... Dr. Darrell Excel Worksheet Functions 6 December 7th 05 08:21 PM
Hide Cell Row and column number alexm999 Excel Discussion (Misc queries) 1 December 1st 05 02:29 PM
copying cell names Al Excel Discussion (Misc queries) 12 August 11th 05 03:01 PM
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 09:43 PM
Hide hyperlink cell & replace with macros Jose Excel Worksheet Functions 1 February 14th 05 08:23 AM


All times are GMT +1. The time now is 07:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"