Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default How to write a macro to hide an entire row

Hello guys,

I would like to write a macro that would hide an entire row if the cells
value in that column is equal to 0.
Someting like this:
A B C
1 20000
2 0 - if c2 = 0 then hide entire row
3 20000


Thank you for your help.

José
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default How to write a macro to hide an entire row

Hi,

Try this

Sub Hide_Me()
Set sht = Sheets("Sheet1") ' Change to suit
lastrow = sht.Cells(Cells.Rows.Count, "C").End(xlUp).Row
For x = lastrow To 1 Step -1
If sht.Cells(x, 3).Value < "" _
And sht.Cells(x, 3).Value = 0 Then
sht.Rows(x).Hidden = True
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"jimmy" wrote:

Hello guys,

I would like to write a macro that would hide an entire row if the cells
value in that column is equal to 0.
Someting like this:
A B C
1 20000
2 0 - if c2 = 0 then hide entire row
3 20000


Thank you for your help.

José

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default How to write a macro to hide an entire row

Jimmy, heres another approach which could be used in any sheet to hide rows
with 0 or blank..

Sub HideRows()
Dim lngRow As Long, lngLastRow As Long

lngLastRow = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, SearchOrder:=xlRows).Row

For lngRow = 1 To lngLastRow
If WorksheetFunction.CountIf(Rows(lngRow), 0) + _
WorksheetFunction.CountBlank(Rows(lngRow)) = _
Columns.Count Then Rows(lngRow).Hidden = True
Next

End Sub

--
Jacob (MVP - Excel)


"Mike H" wrote:

Hi,

Try this

Sub Hide_Me()
Set sht = Sheets("Sheet1") ' Change to suit
lastrow = sht.Cells(Cells.Rows.Count, "C").End(xlUp).Row
For x = lastrow To 1 Step -1
If sht.Cells(x, 3).Value < "" _
And sht.Cells(x, 3).Value = 0 Then
sht.Rows(x).Hidden = True
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"jimmy" wrote:

Hello guys,

I would like to write a macro that would hide an entire row if the cells
value in that column is equal to 0.
Someting like this:
A B C
1 20000
2 0 - if c2 = 0 then hide entire row
3 20000


Thank you for your help.

José

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default How to write a macro to hide an entire row

Mike, sorry my post ended up as a response to your one..which was unintended


"Mike H" wrote:

Hi,

Try this

Sub Hide_Me()
Set sht = Sheets("Sheet1") ' Change to suit
lastrow = sht.Cells(Cells.Rows.Count, "C").End(xlUp).Row
For x = lastrow To 1 Step -1
If sht.Cells(x, 3).Value < "" _
And sht.Cells(x, 3).Value = 0 Then
sht.Rows(x).Hidden = True
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"jimmy" wrote:

Hello guys,

I would like to write a macro that would hide an entire row if the cells
value in that column is equal to 0.
Someting like this:
A B C
1 20000
2 0 - if c2 = 0 then hide entire row
3 20000


Thank you for your help.

José

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default How to write a macro to hide an entire row

Jacob,

No worries. I would include a test for a blank cell in your code, the OP
seemed to be specific in wanting to hide rows with zero.

Mike
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Jacob Skaria" wrote:

Mike, sorry my post ended up as a response to your one..which was unintended


"Mike H" wrote:

Hi,

Try this

Sub Hide_Me()
Set sht = Sheets("Sheet1") ' Change to suit
lastrow = sht.Cells(Cells.Rows.Count, "C").End(xlUp).Row
For x = lastrow To 1 Step -1
If sht.Cells(x, 3).Value < "" _
And sht.Cells(x, 3).Value = 0 Then
sht.Rows(x).Hidden = True
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"jimmy" wrote:

Hello guys,

I would like to write a macro that would hide an entire row if the cells
value in that column is equal to 0.
Someting like this:
A B C
1 20000
2 0 - if c2 = 0 then hide entire row
3 20000


Thank you for your help.

José



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default How to write a macro to hide an entire row

OOPS,

Forgot, congratulations on being appointed MVP, well done and well deserved.
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Mike H" wrote:

Jacob,

No worries. I would include a test for a blank cell in your code, the OP
seemed to be specific in wanting to hide rows with zero.

Mike
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Jacob Skaria" wrote:

Mike, sorry my post ended up as a response to your one..which was unintended


"Mike H" wrote:

Hi,

Try this

Sub Hide_Me()
Set sht = Sheets("Sheet1") ' Change to suit
lastrow = sht.Cells(Cells.Rows.Count, "C").End(xlUp).Row
For x = lastrow To 1 Step -1
If sht.Cells(x, 3).Value < "" _
And sht.Cells(x, 3).Value = 0 Then
sht.Rows(x).Hidden = True
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"jimmy" wrote:

Hello guys,

I would like to write a macro that would hide an entire row if the cells
value in that column is equal to 0.
Someting like this:
A B C
1 20000
2 0 - if c2 = 0 then hide entire row
3 20000


Thank you for your help.

José

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default How to write a macro to hide an entire row

Thanks. I understand the OP is only looking for zeroes.

"Mike H" wrote:

Jacob,

No worries. I would include a test for a blank cell in your code, the OP
seemed to be specific in wanting to hide rows with zero.

Mike
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Jacob Skaria" wrote:

Mike, sorry my post ended up as a response to your one..which was unintended


"Mike H" wrote:

Hi,

Try this

Sub Hide_Me()
Set sht = Sheets("Sheet1") ' Change to suit
lastrow = sht.Cells(Cells.Rows.Count, "C").End(xlUp).Row
For x = lastrow To 1 Step -1
If sht.Cells(x, 3).Value < "" _
And sht.Cells(x, 3).Value = 0 Then
sht.Rows(x).Hidden = True
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"jimmy" wrote:

Hello guys,

I would like to write a macro that would hide an entire row if the cells
value in that column is equal to 0.
Someting like this:
A B C
1 20000
2 0 - if c2 = 0 then hide entire row
3 20000


Thank you for your help.

José

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default How to write a macro to hide an entire row

Thank you JAcob for your help.
Jimmy

"Jacob Skaria" wrote:

Jimmy, heres another approach which could be used in any sheet to hide rows
with 0 or blank..

Sub HideRows()
Dim lngRow As Long, lngLastRow As Long

lngLastRow = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, SearchOrder:=xlRows).Row

For lngRow = 1 To lngLastRow
If WorksheetFunction.CountIf(Rows(lngRow), 0) + _
WorksheetFunction.CountBlank(Rows(lngRow)) = _
Columns.Count Then Rows(lngRow).Hidden = True
Next

End Sub

--
Jacob (MVP - Excel)


"Mike H" wrote:

Hi,

Try this

Sub Hide_Me()
Set sht = Sheets("Sheet1") ' Change to suit
lastrow = sht.Cells(Cells.Rows.Count, "C").End(xlUp).Row
For x = lastrow To 1 Step -1
If sht.Cells(x, 3).Value < "" _
And sht.Cells(x, 3).Value = 0 Then
sht.Rows(x).Hidden = True
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"jimmy" wrote:

Hello guys,

I would like to write a macro that would hide an entire row if the cells
value in that column is equal to 0.
Someting like this:
A B C
1 20000
2 0 - if c2 = 0 then hide entire row
3 20000


Thank you for your help.

José

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default How to write a macro to hide an entire row

Thank you mike for your help.
Jimmy

"Mike H" wrote:

Hi,

Try this

Sub Hide_Me()
Set sht = Sheets("Sheet1") ' Change to suit
lastrow = sht.Cells(Cells.Rows.Count, "C").End(xlUp).Row
For x = lastrow To 1 Step -1
If sht.Cells(x, 3).Value < "" _
And sht.Cells(x, 3).Value = 0 Then
sht.Rows(x).Hidden = True
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"jimmy" wrote:

Hello guys,

I would like to write a macro that would hide an entire row if the cells
value in that column is equal to 0.
Someting like this:
A B C
1 20000
2 0 - if c2 = 0 then hide entire row
3 20000


Thank you for your help.

José

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
How I write "if cell value =1, copy entire row & paste at dest. Dick Kusleika[_4_] Excel Programming 0 May 28th 08 04:42 PM
Hide Entire Row If Cell = 0 Sean[_15_] Excel Programming 8 August 29th 06 08:58 PM
Hide an entire tab. ChuckF Excel Worksheet Functions 3 March 28th 06 05:52 PM
Hide an entire row - Not working Mark Excel Programming 2 September 14th 05 09:13 PM
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM


All times are GMT +1. The time now is 06:15 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"