Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default hide rows based on value

Hi all,

Here's my problem...

I have written a nice spreadsheet for writing proposals for work. I would
like to create two macros.

"shrink list" and "expand list"

I have set all cells in column A to be a value based on column B. Once I
have completed my proposal, I would like to click "shrink list" to hide all
ROWS that have "0" (zero) as it's value. And then be able to click "expand
list" to show all rows again. Essentially, the macro will look only at column
A and hide all of the rows that show a zero.

I know that I can do this with autofilter, but this needs to be simple for
less knowledgeable users.

Can someone help?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default hide rows based on value

Try:

Private Sub CommandButton1_Click() 'ShrinkList
Dim eRow As Long
Dim i As Long
On Error GoTo Exit_Click
Application.ScreenUpdating = False
eRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To eRow
If Cells(i, 1).Value = 0 Then
Rows(i).EntireRow.Hidden = True
End If
Next i
Exit_Click:
Application.ScreenUpdating = True
End Sub

Private Sub CommandButton2_Click() 'Expand List
Rows.Hidden = False
End Sub

Hope this helps
Rowan

MTomlinson wrote:
Hi all,

Here's my problem...

I have written a nice spreadsheet for writing proposals for work. I would
like to create two macros.

"shrink list" and "expand list"

I have set all cells in column A to be a value based on column B. Once I
have completed my proposal, I would like to click "shrink list" to hide all
ROWS that have "0" (zero) as it's value. And then be able to click "expand
list" to show all rows again. Essentially, the macro will look only at column
A and hide all of the rows that show a zero.

I know that I can do this with autofilter, but this needs to be simple for
less knowledgeable users.

Can someone help?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default hide rows based on value

Will try...thank you! is this two seperate macros? will this allow me to
have two different buttons or just toggle?

"Rowan Drummond" wrote:

Try:

Private Sub CommandButton1_Click() 'ShrinkList
Dim eRow As Long
Dim i As Long
On Error GoTo Exit_Click
Application.ScreenUpdating = False
eRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To eRow
If Cells(i, 1).Value = 0 Then
Rows(i).EntireRow.Hidden = True
End If
Next i
Exit_Click:
Application.ScreenUpdating = True
End Sub

Private Sub CommandButton2_Click() 'Expand List
Rows.Hidden = False
End Sub

Hope this helps
Rowan

MTomlinson wrote:
Hi all,

Here's my problem...

I have written a nice spreadsheet for writing proposals for work. I would
like to create two macros.

"shrink list" and "expand list"

I have set all cells in column A to be a value based on column B. Once I
have completed my proposal, I would like to click "shrink list" to hide all
ROWS that have "0" (zero) as it's value. And then be able to click "expand
list" to show all rows again. Essentially, the macro will look only at column
A and hide all of the rows that show a zero.

I know that I can do this with autofilter, but this needs to be simple for
less knowledgeable users.

Can someone help?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default hide rows based on value

It is two seperate events for two seperate buttons from the Control
Toolbox - CommandButton1 and CommandButton2. I guess if you wanted a
toggle button that could be arranged.

Regards
Rowan

MTomlinson wrote:
Will try...thank you! is this two seperate macros? will this allow me to
have two different buttons or just toggle?

"Rowan Drummond" wrote:


Try:

Private Sub CommandButton1_Click() 'ShrinkList
Dim eRow As Long
Dim i As Long
On Error GoTo Exit_Click
Application.ScreenUpdating = False
eRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To eRow
If Cells(i, 1).Value = 0 Then
Rows(i).EntireRow.Hidden = True
End If
Next i
Exit_Click:
Application.ScreenUpdating = True
End Sub

Private Sub CommandButton2_Click() 'Expand List
Rows.Hidden = False
End Sub

Hope this helps
Rowan

MTomlinson wrote:

Hi all,

Here's my problem...

I have written a nice spreadsheet for writing proposals for work. I would
like to create two macros.

"shrink list" and "expand list"

I have set all cells in column A to be a value based on column B. Once I
have completed my proposal, I would like to click "shrink list" to hide all
ROWS that have "0" (zero) as it's value. And then be able to click "expand
list" to show all rows again. Essentially, the macro will look only at column
A and hide all of the rows that show a zero.

I know that I can do this with autofilter, but this needs to be simple for
less knowledgeable users.

Can someone help?


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
Hide Rows based on value, but not using autofilter Richhall[_2_] Excel Worksheet Functions 2 November 11th 09 02:31 PM
Hide Rows based on value SteveT Excel Discussion (Misc queries) 0 June 27th 06 11:00 PM
hide rows based on cell value dummster New Users to Excel 1 February 15th 06 11:37 PM
hide rows based on value in cell dummster Excel Discussion (Misc queries) 0 February 15th 06 03:27 PM
How to Hide Rows based on conditional value in cell Nick Excel Programming 1 May 21st 04 11:16 AM


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