#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 61
Default Macro to hide rows

I have formulas in consecutive rows, but I want to run a macro that will hide
the rows that equal 0, and if they change and don't equal 0, the row will
unhide. Is there a code for this? (I'm using Excel 2003)

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 913
Default Macro to hide rows

On Fri, 11 Jul 2008 08:15:01 -0700, lightbulb
wrote:

I have formulas in consecutive rows, but I want to run a macro that will hide
the rows that equal 0, and if they change and don't equal 0, the row will
unhide. Is there a code for this? (I'm using Excel 2003)

Thanks!



Try this:

Private Sub Worksheet_Change(ByVal Target As Range)
maxrownumber = 100
column_to_test = 1
For i = 1 To maxrownumber
If Cells(i, column_to_test).HasFormula Then
Rows(i).EntireRow.Hidden = (Cells(i, 1) = 0)
End If
Next i
End Sub

You can play with the maxrownumber and column_to_test to suit your
needs.

Hope this helps / Lars-Åke

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 913
Default Macro to hide rows

On Fri, 11 Jul 2008 16:08:11 GMT, Lars-Åke Aspelin
wrote:

On Fri, 11 Jul 2008 08:15:01 -0700, lightbulb
wrote:

I have formulas in consecutive rows, but I want to run a macro that will hide
the rows that equal 0, and if they change and don't equal 0, the row will
unhide. Is there a code for this? (I'm using Excel 2003)

Thanks!



Try this:

Private Sub Worksheet_Change(ByVal Target As Range)
maxrownumber = 100
column_to_test = 1
For i = 1 To maxrownumber
If Cells(i, column_to_test).HasFormula Then
Rows(i).EntireRow.Hidden = (Cells(i, 1) = 0)
End If
Next i
End Sub

You can play with the maxrownumber and column_to_test to suit your
needs.

Hope this helps / Lars-Åke


Oops, forgot to change one of the 1's to column_to_test.


Private Sub Worksheet_Change(ByVal Target As Range)
maxrownumber = 100
column_to_test = 1
For i = 1 To maxrownumber
If Cells(i, column_to_test).HasFormula Then
Rows(i).EntireRow.Hidden = (Cells(i, column_to_test) = 0)
End If
Next i
End Sub
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 61
Default Macro to hide rows

This did not work. In excel, I went to Tools-Macro-and named a new macro,
then I simply copy and pasted your macro into the Visual Basic code and it
did not work. Am I doing something wrong?
Thanks!

"Lars-Ã…ke Aspelin" wrote:

On Fri, 11 Jul 2008 16:08:11 GMT, Lars-Ã…ke Aspelin
wrote:

On Fri, 11 Jul 2008 08:15:01 -0700, lightbulb
wrote:

I have formulas in consecutive rows, but I want to run a macro that will hide
the rows that equal 0, and if they change and don't equal 0, the row will
unhide. Is there a code for this? (I'm using Excel 2003)

Thanks!



Try this:

Private Sub Worksheet_Change(ByVal Target As Range)
maxrownumber = 100
column_to_test = 1
For i = 1 To maxrownumber
If Cells(i, column_to_test).HasFormula Then
Rows(i).EntireRow.Hidden = (Cells(i, 1) = 0)
End If
Next i
End Sub

You can play with the maxrownumber and column_to_test to suit your
needs.

Hope this helps / Lars-Ã…ke


Oops, forgot to change one of the 1's to column_to_test.


Private Sub Worksheet_Change(ByVal Target As Range)
maxrownumber = 100
column_to_test = 1
For i = 1 To maxrownumber
If Cells(i, column_to_test).HasFormula Then
Rows(i).EntireRow.Hidden = (Cells(i, column_to_test) = 0)
End If
Next i
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 964
Default Macro to hide rows

Right click the sheet tab where you want this macro and select view code,
paste it there

--


Regards,


Peo Sjoblom

"lightbulb" wrote in message
...
This did not work. In excel, I went to Tools-Macro-and named a new macro,
then I simply copy and pasted your macro into the Visual Basic code and it
did not work. Am I doing something wrong?
Thanks!

"Lars-Åke Aspelin" wrote:

On Fri, 11 Jul 2008 16:08:11 GMT, Lars-Åke Aspelin
wrote:

On Fri, 11 Jul 2008 08:15:01 -0700, lightbulb
wrote:

I have formulas in consecutive rows, but I want to run a macro that
will hide
the rows that equal 0, and if they change and don't equal 0, the row
will
unhide. Is there a code for this? (I'm using Excel 2003)

Thanks!


Try this:

Private Sub Worksheet_Change(ByVal Target As Range)
maxrownumber = 100
column_to_test = 1
For i = 1 To maxrownumber
If Cells(i, column_to_test).HasFormula Then
Rows(i).EntireRow.Hidden = (Cells(i, 1) = 0)
End If
Next i
End Sub

You can play with the maxrownumber and column_to_test to suit your
needs.

Hope this helps / Lars-Åke


Oops, forgot to change one of the 1's to column_to_test.


Private Sub Worksheet_Change(ByVal Target As Range)
maxrownumber = 100
column_to_test = 1
For i = 1 To maxrownumber
If Cells(i, column_to_test).HasFormula Then
Rows(i).EntireRow.Hidden = (Cells(i, column_to_test) = 0)
End If
Next i
End Sub



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 to hide rows not working Al Excel Discussion (Misc queries) 14 September 16th 08 05:53 PM
Macro/code to hide rows Smatass Excel Worksheet Functions 1 September 25th 07 01:57 AM
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 03:59 PM.

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"