Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 28
Default Macro to Hide rows based on value of column F

I looked through all the similar questions but couldn't find the answer I'm
looking for. I would like to have two buttons. One to "Show Active Files".
This would hide all rows in which column F has either "Withdrawn" or
"Declined". And the other button would be "Show All Files". This would
unhide anything that is hidden.

If anyone has any suggestions it would be greatly appreciated.
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 28
Default Macro to Hide rows based on value of column F

I actually already use autofiler for other purposes. I'm not sure how it
would work with the filter, unfilter, filter again. Plus, right now the
worksheet is blank. I suppose in order to record a macro where I rearrange
all the data and the select the ones that I want to hide, I would need to
make up at least some data to put in just for that purpose. I was hoping
there was a macro that I could assign to the two buttons that would just hide
the rows where "Withdrawn" or "Declined" is in column F or unhide them.

Thanks,
Scott

"Don Guillett" wrote:

use datafilterautofilter. Record a macro if desired. use autofilter again
or showall to remove the filter.

--
Don Guillett
SalesAid Software

"Scott Marcus" wrote in message
...
I looked through all the similar questions but couldn't find the answer I'm
looking for. I would like to have two buttons. One to "Show Active
Files".
This would hide all rows in which column F has either "Withdrawn" or
"Declined". And the other button would be "Show All Files". This would
unhide anything that is hidden.

If anyone has any suggestions it would be greatly appreciated.




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Macro to Hide rows based on value of column F

An autofilter macro would be best but you could always use a loop

Option Compare Text 'put this line at the top of the regular module

Sub hiderowsif()
lr = Cells(Rows.Count, "a").End(xlUp).Row
For i = lr To 2 Step -1
If Cells(i, "a") = "Withdrawn" Or Cells(i, "a") = "Declined" Then
Rows(i).Hidden = True
Next i
End Sub
--
Don Guillett
SalesAid Software

"Scott Marcus" wrote in message
...
I actually already use autofiler for other purposes. I'm not sure how it
would work with the filter, unfilter, filter again. Plus, right now the
worksheet is blank. I suppose in order to record a macro where I
rearrange
all the data and the select the ones that I want to hide, I would need to
make up at least some data to put in just for that purpose. I was hoping
there was a macro that I could assign to the two buttons that would just
hide
the rows where "Withdrawn" or "Declined" is in column F or unhide them.

Thanks,
Scott

"Don Guillett" wrote:

use datafilterautofilter. Record a macro if desired. use autofilter
again
or showall to remove the filter.

--
Don Guillett
SalesAid Software

"Scott Marcus" wrote in message
...
I looked through all the similar questions but couldn't find the answer
I'm
looking for. I would like to have two buttons. One to "Show Active
Files".
This would hide all rows in which column F has either "Withdrawn" or
"Declined". And the other button would be "Show All Files". This
would
unhide anything that is hidden.

If anyone has any suggestions it would be greatly appreciated.






  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 28
Default Macro to Hide rows based on value of column F

I didn't realize that the autofilter would be part of the macro. How would I
do that without manually recording one? Also, if I go with the one you sent
me, what would be the macro for the "unhide" button?

Thanks again,
Scott

"Don Guillett" wrote:

An autofilter macro would be best but you could always use a loop

Option Compare Text 'put this line at the top of the regular module

Sub hiderowsif()
lr = Cells(Rows.Count, "a").End(xlUp).Row
For i = lr To 2 Step -1
If Cells(i, "a") = "Withdrawn" Or Cells(i, "a") = "Declined" Then
Rows(i).Hidden = True
Next i
End Sub
--
Don Guillett
SalesAid Software

"Scott Marcus" wrote in message
...
I actually already use autofiler for other purposes. I'm not sure how it
would work with the filter, unfilter, filter again. Plus, right now the
worksheet is blank. I suppose in order to record a macro where I
rearrange
all the data and the select the ones that I want to hide, I would need to
make up at least some data to put in just for that purpose. I was hoping
there was a macro that I could assign to the two buttons that would just
hide
the rows where "Withdrawn" or "Declined" is in column F or unhide them.

Thanks,
Scott

"Don Guillett" wrote:

use datafilterautofilter. Record a macro if desired. use autofilter
again
or showall to remove the filter.

--
Don Guillett
SalesAid Software

"Scott Marcus" wrote in message
...
I looked through all the similar questions but couldn't find the answer
I'm
looking for. I would like to have two buttons. One to "Show Active
Files".
This would hide all rows in which column F has either "Withdrawn" or
"Declined". And the other button would be "Show All Files". This
would
unhide anything that is hidden.

If anyone has any suggestions it would be greatly appreciated.








  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Macro to Hide rows based on value of column F

Scott

Assign each of these to your buttons.

Sub HideRows_2Params()
'Bob Phillips Aug. 26, 2006
'slight modifications
Dim iLastRow As Long
Dim i As Long
iLastRow = Cells(Rows.Count, "F").End(xlUp).Row
For i = iLastRow To 1 Step -1
If Cells(i, "F").Value < "" Or _
(Len(Cells(i, "F").Value) = "WithDrawn" Or _
Cells(i, "F").Value = "Declined") Then
Rows(i).EntireRow.Hidden = True
End If
Next i

End Sub

Sub UnHideRows()
Cells.Select
Selection.EntireRow.Hidden = False
Range("A1").Select
End Sub


Gord Dibben MS Excel MVP


On Thu, 26 Oct 2006 12:34:02 -0700, Scott Marcus
wrote:

I looked through all the similar questions but couldn't find the answer I'm
looking for. I would like to have two buttons. One to "Show Active Files".
This would hide all rows in which column F has either "Withdrawn" or
"Declined". And the other button would be "Show All Files". This would
unhide anything that is hidden.

If anyone has any suggestions it would be greatly appreciated.


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 28
Default Macro to Hide rows based on value of column F

You must be close, but this is what happens: it hides every row which has
anything in column F, not just the ones with "withdrawn" or "declined". The
unhide works fine.

Thanks

"Gord Dibben" wrote:

Scott

Assign each of these to your buttons.

Sub HideRows_2Params()
'Bob Phillips Aug. 26, 2006
'slight modifications
Dim iLastRow As Long
Dim i As Long
iLastRow = Cells(Rows.Count, "F").End(xlUp).Row
For i = iLastRow To 1 Step -1
If Cells(i, "F").Value < "" Or _
(Len(Cells(i, "F").Value) = "WithDrawn" Or _
Cells(i, "F").Value = "Declined") Then
Rows(i).EntireRow.Hidden = True
End If
Next i

End Sub

Sub UnHideRows()
Cells.Select
Selection.EntireRow.Hidden = False
Range("A1").Select
End Sub


Gord Dibben MS Excel MVP


On Thu, 26 Oct 2006 12:34:02 -0700, Scott Marcus
wrote:

I looked through all the similar questions but couldn't find the answer I'm
looking for. I would like to have two buttons. One to "Show Active Files".
This would hide all rows in which column F has either "Withdrawn" or
"Declined". And the other button would be "Show All Files". This would
unhide anything that is hidden.

If anyone has any suggestions it would be greatly appreciated.



  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Macro to Hide rows based on value of column F

Sub unhiderows()
Cells.Rows.Hidden = False
End Sub


--
Don Guillett
SalesAid Software

"Scott Marcus" wrote in message
...
I didn't realize that the autofilter would be part of the macro. How would
I
do that without manually recording one? Also, if I go with the one you
sent
me, what would be the macro for the "unhide" button?

Thanks again,
Scott

"Don Guillett" wrote:

An autofilter macro would be best but you could always use a loop

Option Compare Text 'put this line at the top of the regular module

Sub hiderowsif()
lr = Cells(Rows.Count, "a").End(xlUp).Row
For i = lr To 2 Step -1
If Cells(i, "a") = "Withdrawn" Or Cells(i, "a") = "Declined" Then
Rows(i).Hidden = True
Next i
End Sub
--
Don Guillett
SalesAid Software

"Scott Marcus" wrote in message
...
I actually already use autofiler for other purposes. I'm not sure how
it
would work with the filter, unfilter, filter again. Plus, right now the
worksheet is blank. I suppose in order to record a macro where I
rearrange
all the data and the select the ones that I want to hide, I would need
to
make up at least some data to put in just for that purpose. I was
hoping
there was a macro that I could assign to the two buttons that would
just
hide
the rows where "Withdrawn" or "Declined" is in column F or unhide them.

Thanks,
Scott

"Don Guillett" wrote:

use datafilterautofilter. Record a macro if desired. use autofilter
again
or showall to remove the filter.

--
Don Guillett
SalesAid Software

"Scott Marcus" wrote in
message
...
I looked through all the similar questions but couldn't find the
answer
I'm
looking for. I would like to have two buttons. One to "Show Active
Files".
This would hide all rows in which column F has either "Withdrawn" or
"Declined". And the other button would be "Show All Files". This
would
unhide anything that is hidden.

If anyone has any suggestions it would be greatly appreciated.








  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Macro to Hide rows based on value of column F

Sorry Scott(and Bob)

Try this.

Option Compare Text
Sub HideRows_2Params()
'Bob Phillips Aug. 26, 2006
'modified by Gord Dibben
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "F").End(xlUp).Row
For i = iLastRow To 1 Step -1
If Cells(i, "F").Value < "" And _
Cells(i, "F").Value = "withdrawn" Or _
Cells(i, "F").Value = "declined" Then
Rows(i).EntireRow.Hidden = True
End If
Next i

End Sub


Gord

On Thu, 26 Oct 2006 14:13:01 -0700, Scott Marcus
wrote:

You must be close, but this is what happens: it hides every row which has
anything in column F, not just the ones with "withdrawn" or "declined". The
unhide works fine.

Thanks

"Gord Dibben" wrote:

Scott

Assign each of these to your buttons.

Sub HideRows_2Params()
'Bob Phillips Aug. 26, 2006
'slight modifications
Dim iLastRow As Long
Dim i As Long
iLastRow = Cells(Rows.Count, "F").End(xlUp).Row
For i = iLastRow To 1 Step -1
If Cells(i, "F").Value < "" Or _
(Len(Cells(i, "F").Value) = "WithDrawn" Or _
Cells(i, "F").Value = "Declined") Then
Rows(i).EntireRow.Hidden = True
End If
Next i

End Sub

Sub UnHideRows()
Cells.Select
Selection.EntireRow.Hidden = False
Range("A1").Select
End Sub


Gord Dibben MS Excel MVP


On Thu, 26 Oct 2006 12:34:02 -0700, Scott Marcus
wrote:

I looked through all the similar questions but couldn't find the answer I'm
looking for. I would like to have two buttons. One to "Show Active Files".
This would hide all rows in which column F has either "Withdrawn" or
"Declined". And the other button would be "Show All Files". This would
unhide anything that is hidden.

If anyone has any suggestions it would be greatly appreciated.




Gord Dibben MS Excel MVP
  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 28
Default Macro to Hide rows based on value of column F

This gives an error message saying "Compile error: next without for"

"Don Guillett" wrote:

An autofilter macro would be best but you could always use a loop

Option Compare Text 'put this line at the top of the regular module

Sub hiderowsif()
lr = Cells(Rows.Count, "a").End(xlUp).Row
For i = lr To 2 Step -1
If Cells(i, "a") = "Withdrawn" Or Cells(i, "a") = "Declined" Then
Rows(i).Hidden = True
Next i
End Sub
--
Don Guillett
SalesAid Software

"Scott Marcus" wrote in message
...
I actually already use autofiler for other purposes. I'm not sure how it
would work with the filter, unfilter, filter again. Plus, right now the
worksheet is blank. I suppose in order to record a macro where I
rearrange
all the data and the select the ones that I want to hide, I would need to
make up at least some data to put in just for that purpose. I was hoping
there was a macro that I could assign to the two buttons that would just
hide
the rows where "Withdrawn" or "Declined" is in column F or unhide them.

Thanks,
Scott

"Don Guillett" wrote:

use datafilterautofilter. Record a macro if desired. use autofilter
again
or showall to remove the filter.

--
Don Guillett
SalesAid Software

"Scott Marcus" wrote in message
...
I looked through all the similar questions but couldn't find the answer
I'm
looking for. I would like to have two buttons. One to "Show Active
Files".
This would hide all rows in which column F has either "Withdrawn" or
"Declined". And the other button would be "Show All Files". This
would
unhide anything that is hidden.

If anyone has any suggestions it would be greatly appreciated.








  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Macro to Hide rows based on value of column F

change to ONE line or use end if as the line after
If Cells(i, "a") = "Withdrawn" Or Cells(i, "a") = "Declined" Then
Rows(i).Hidden = True



--
Don Guillett
SalesAid Software

"Scott Marcus" wrote in message
...
This gives an error message saying "Compile error: next without for"

"Don Guillett" wrote:

An autofilter macro would be best but you could always use a loop

Option Compare Text 'put this line at the top of the regular module

Sub hiderowsif()
lr = Cells(Rows.Count, "a").End(xlUp).Row
For i = lr To 2 Step -1
If Cells(i, "a") = "Withdrawn" Or Cells(i, "a") = "Declined" Then
Rows(i).Hidden = True
Next i
End Sub
--
Don Guillett
SalesAid Software

"Scott Marcus" wrote in message
...
I actually already use autofiler for other purposes. I'm not sure how
it
would work with the filter, unfilter, filter again. Plus, right now the
worksheet is blank. I suppose in order to record a macro where I
rearrange
all the data and the select the ones that I want to hide, I would need
to
make up at least some data to put in just for that purpose. I was
hoping
there was a macro that I could assign to the two buttons that would
just
hide
the rows where "Withdrawn" or "Declined" is in column F or unhide them.

Thanks,
Scott

"Don Guillett" wrote:

use datafilterautofilter. Record a macro if desired. use autofilter
again
or showall to remove the filter.

--
Don Guillett
SalesAid Software

"Scott Marcus" wrote in
message
...
I looked through all the similar questions but couldn't find the
answer
I'm
looking for. I would like to have two buttons. One to "Show Active
Files".
This would hide all rows in which column F has either "Withdrawn" or
"Declined". And the other button would be "Show All Files". This
would
unhide anything that is hidden.

If anyone has any suggestions it would be greatly appreciated.








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 Help Needed: Comparing cell values and deleting rows [email protected] Excel Discussion (Misc queries) 1 September 19th 06 02:39 AM
macro unouwanme Excel Discussion (Misc queries) 9 August 31st 06 09:38 PM
How can I invoke running a macro from within an "IF" function. ron Excel Worksheet Functions 11 February 8th 06 03:35 PM
Return SEARCHED Column Number of Numeric Label and Value Sam via OfficeKB.com Excel Worksheet Functions 23 January 30th 06 06:16 PM
Hide column or row based on a cell in the column or row? SacGuy Excel Discussion (Misc queries) 0 January 24th 06 06:51 PM


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