Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
al al is offline
external usenet poster
 
Posts: 363
Default Macro to hide rows not working

What I'm trying to achieve is the automatic hiding of entire rows if the
value of a cell, in this case in column B, is < 1. The below example
works...row 6 is hidden.

Sub hide_row()
If Range("B6").Value < 1 Then Range("B6").EntireRow.Hidden = True
End Sub

But when I try to impose this upon a range of column B, then, alas, not the
desired result!

If Range("B6,B9").Value < 1 Then Range("B6,B9").EntireRow.Hidden = True

Can anyone point me in the right direction? Thanks in advance!

Al
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Macro to hide rows not working

Hi,

Right click your sheet tab, view code and paste this in

Sub sonic()
LastRow = Cells(Cells.Rows.Count, "B").End(xlUp).Row
Set myrange = Range("B1:B" & LastRow)
For Each c In myrange
If c.Value < "" And c.Value < 1 Then
c.EntireRow.Hidden = True
End If
Next
End Sub

Mike

"Al" wrote:

What I'm trying to achieve is the automatic hiding of entire rows if the
value of a cell, in this case in column B, is < 1. The below example
works...row 6 is hidden.

Sub hide_row()
If Range("B6").Value < 1 Then Range("B6").EntireRow.Hidden = True
End Sub

But when I try to impose this upon a range of column B, then, alas, not the
desired result!

If Range("B6,B9").Value < 1 Then Range("B6,B9").EntireRow.Hidden = True

Can anyone point me in the right direction? Thanks in advance!

Al

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Macro to hide rows not working

Sub hide_row()
For Each cell In Range("B6,B9")
cell.EntireRow.Hidden = cell..Value < 1
Next cell
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Al" wrote in message
...
What I'm trying to achieve is the automatic hiding of entire rows if the
value of a cell, in this case in column B, is < 1. The below example
works...row 6 is hidden.

Sub hide_row()
If Range("B6").Value < 1 Then Range("B6").EntireRow.Hidden = True
End Sub

But when I try to impose this upon a range of column B, then, alas, not
the
desired result!

If Range("B6,B9").Value < 1 Then Range("B6,B9").EntireRow.Hidden = True

Can anyone point me in the right direction? Thanks in advance!

Al



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Macro to hide rows not working

Too many dots

Sub hide_row()
For Each cell In Range("B6,B9")
cell.EntireRow.Hidden = cell.Value < 1
Next cell
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Bob Phillips" wrote in message
...
Sub hide_row()
For Each cell In Range("B6,B9")
cell.EntireRow.Hidden = cell..Value < 1
Next cell
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Al" wrote in message
...
What I'm trying to achieve is the automatic hiding of entire rows if the
value of a cell, in this case in column B, is < 1. The below example
works...row 6 is hidden.

Sub hide_row()
If Range("B6").Value < 1 Then Range("B6").EntireRow.Hidden = True
End Sub

But when I try to impose this upon a range of column B, then, alas, not
the
desired result!

If Range("B6,B9").Value < 1 Then Range("B6,B9").EntireRow.Hidden = True

Can anyone point me in the right direction? Thanks in advance!

Al





  #5   Report Post  
Posted to microsoft.public.excel.misc
al al is offline
external usenet poster
 
Posts: 363
Default Macro to hide rows not working

Bob, this seems to work for cells B6 and B9 only...but not the range. i.e. I
also have B7<1, but this row is not hidden.
Thanks for your help!

"Bob Phillips" wrote:

Too many dots

Sub hide_row()
For Each cell In Range("B6,B9")
cell.EntireRow.Hidden = cell.Value < 1
Next cell
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Bob Phillips" wrote in message
...
Sub hide_row()
For Each cell In Range("B6,B9")
cell.EntireRow.Hidden = cell..Value < 1
Next cell
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Al" wrote in message
...
What I'm trying to achieve is the automatic hiding of entire rows if the
value of a cell, in this case in column B, is < 1. The below example
works...row 6 is hidden.

Sub hide_row()
If Range("B6").Value < 1 Then Range("B6").EntireRow.Hidden = True
End Sub

But when I try to impose this upon a range of column B, then, alas, not
the
desired result!

If Range("B6,B9").Value < 1 Then Range("B6,B9").EntireRow.Hidden = True

Can anyone point me in the right direction? Thanks in advance!

Al








  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Macro to hide rows not working

I thought that was how you wanted it Al <g.

Try

Sub hide_row()
For Each cell In Range("B6:B9")
cell.EntireRow.Hidden = cell.Value < 1
Next cell
End Sub



--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Al" wrote in message
...
Bob, this seems to work for cells B6 and B9 only...but not the range. i.e.
I
also have B7<1, but this row is not hidden.
Thanks for your help!

"Bob Phillips" wrote:

Too many dots

Sub hide_row()
For Each cell In Range("B6,B9")
cell.EntireRow.Hidden = cell.Value < 1
Next cell
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Bob Phillips" wrote in message
...
Sub hide_row()
For Each cell In Range("B6,B9")
cell.EntireRow.Hidden = cell..Value < 1
Next cell
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Al" wrote in message
...
What I'm trying to achieve is the automatic hiding of entire rows if
the
value of a cell, in this case in column B, is < 1. The below example
works...row 6 is hidden.

Sub hide_row()
If Range("B6").Value < 1 Then Range("B6").EntireRow.Hidden = True
End Sub

But when I try to impose this upon a range of column B, then, alas,
not
the
desired result!

If Range("B6,B9").Value < 1 Then Range("B6,B9").EntireRow.Hidden =
True

Can anyone point me in the right direction? Thanks in advance!

Al








  #7   Report Post  
Posted to microsoft.public.excel.misc
al al is offline
external usenet poster
 
Posts: 363
Default Macro to hide rows not working

Bob, many thanks. I'll give this one a go first thing in the morning once I'm
back in the office.

Can you advise me a good place to start learning all this "VBA macro stuff"?!

Al

"Bob Phillips" wrote:

I thought that was how you wanted it Al <g.

Try

Sub hide_row()
For Each cell In Range("B6:B9")
cell.EntireRow.Hidden = cell.Value < 1
Next cell
End Sub



--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Al" wrote in message
...
Bob, this seems to work for cells B6 and B9 only...but not the range. i.e.
I
also have B7<1, but this row is not hidden.
Thanks for your help!

"Bob Phillips" wrote:

Too many dots

Sub hide_row()
For Each cell In Range("B6,B9")
cell.EntireRow.Hidden = cell.Value < 1
Next cell
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Bob Phillips" wrote in message
...
Sub hide_row()
For Each cell In Range("B6,B9")
cell.EntireRow.Hidden = cell..Value < 1
Next cell
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Al" wrote in message
...
What I'm trying to achieve is the automatic hiding of entire rows if
the
value of a cell, in this case in column B, is < 1. The below example
works...row 6 is hidden.

Sub hide_row()
If Range("B6").Value < 1 Then Range("B6").EntireRow.Hidden = True
End Sub

But when I try to impose this upon a range of column B, then, alas,
not
the
desired result!

If Range("B6,B9").Value < 1 Then Range("B6,B9").EntireRow.Hidden =
True

Can anyone point me in the right direction? Thanks in advance!

Al









  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default Macro to hide rows not working

This is just what i've been looking for, but I also want blank cells included.
--
Medzzz


"Bob Phillips" wrote:

I thought that was how you wanted it Al <g.

Try

Sub hide_row()
For Each cell In Range("B6:B9")
cell.EntireRow.Hidden = cell.Value < 1
Next cell
End Sub



--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Al" wrote in message
...
Bob, this seems to work for cells B6 and B9 only...but not the range. i.e.
I
also have B7<1, but this row is not hidden.
Thanks for your help!

"Bob Phillips" wrote:

Too many dots

Sub hide_row()
For Each cell In Range("B6,B9")
cell.EntireRow.Hidden = cell.Value < 1
Next cell
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Bob Phillips" wrote in message
...
Sub hide_row()
For Each cell In Range("B6,B9")
cell.EntireRow.Hidden = cell..Value < 1
Next cell
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Al" wrote in message
...
What I'm trying to achieve is the automatic hiding of entire rows if
the
value of a cell, in this case in column B, is < 1. The below example
works...row 6 is hidden.

Sub hide_row()
If Range("B6").Value < 1 Then Range("B6").EntireRow.Hidden = True
End Sub

But when I try to impose this upon a range of column B, then, alas,
not
the
desired result!

If Range("B6,B9").Value < 1 Then Range("B6,B9").EntireRow.Hidden =
True

Can anyone point me in the right direction? Thanks in advance!

Al









  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Macro to hide rows not working

I'm a newbie on macro function. here is my file
http://i228.photobucket.com/albums/e...onproblem3.jpg

i want to create a macro that would automatically hide the blank cells (the
cells cannot be deleted because it has formula)

how do i go about it?

"Bob Phillips" wrote:

Sub hide_row()
For Each cell In Range("B6,B9")
cell.EntireRow.Hidden = cell..Value < 1
Next cell
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Al" wrote in message
...
What I'm trying to achieve is the automatic hiding of entire rows if the
value of a cell, in this case in column B, is < 1. The below example
works...row 6 is hidden.

Sub hide_row()
If Range("B6").Value < 1 Then Range("B6").EntireRow.Hidden = True
End Sub

But when I try to impose this upon a range of column B, then, alas, not
the
desired result!

If Range("B6,B9").Value < 1 Then Range("B6,B9").EntireRow.Hidden = True

Can anyone point me in the right direction? Thanks in advance!

Al




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
Macro/code to hide rows Smatass Excel Worksheet Functions 1 September 25th 07 01:57 AM
Macro to Hide rows based on value of column F Scott Marcus Excel Discussion (Misc queries) 10 October 27th 06 11:57 PM
Macro that will unhide then hide rows minka Excel Discussion (Misc queries) 10 October 21st 06 01:37 PM
hide rows with macro Macro to hide rows in spreadwsheet Excel Discussion (Misc queries) 3 May 12th 05 05:02 PM
macro to hide rows david Excel Discussion (Misc queries) 3 April 8th 05 03:25 PM


All times are GMT +1. The time now is 10:03 AM.

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

About Us

"It's about Microsoft Excel"