Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Turquoise_dax
 
Posts: n/a
Default How to program a macro to hide rows with conditionnal formating


I have a table with various rows, identified, lets say, by the type of
info (Requirements / Guidelines / Info). I want to program a macro (for
a button) to hide all rows that contains "Info" in the "type" column.

I do not want to enter the number of the row in the macro, because if a
row is inserted, the program has to be revised.

I would also need a macro to automatically unhide all rows.

Thanx a lot!


--
Turquoise_dax
------------------------------------------------------------------------
Turquoise_dax's Profile: http://www.excelforum.com/member.php...o&userid=35185
View this thread: http://www.excelforum.com/showthread...hreadid=553626

  #2   Report Post  
Posted to microsoft.public.excel.misc
CLR
 
Posts: n/a
Default How to program a macro to hide rows with conditionnal formating

One way wothout having to use a macro would be to do Data Filter
AutoFilter and on column "type" choose Custom Does NOT contain Info

This will then show only those rows that do not contain "info" in the "type"
column. To reverse the situation back to normal, just do Data Filter
AutoFilter again......it toggles back.

hth
Vaya con Dios,
Chuck, CABGx3


"Turquoise_dax" wrote:


I have a table with various rows, identified, lets say, by the type of
info (Requirements / Guidelines / Info). I want to program a macro (for
a button) to hide all rows that contains "Info" in the "type" column.

I do not want to enter the number of the row in the macro, because if a
row is inserted, the program has to be revised.

I would also need a macro to automatically unhide all rows.

Thanx a lot!


--
Turquoise_dax
------------------------------------------------------------------------
Turquoise_dax's Profile: http://www.excelforum.com/member.php...o&userid=35185
View this thread: http://www.excelforum.com/showthread...hreadid=553626


  #3   Report Post  
Posted to microsoft.public.excel.misc
Turquoise_dax
 
Posts: n/a
Default How to program a macro to hide rows with conditionnal formating


I need to use a macro, because it is to be linked to a button.

I tried this code:

ActiveSheet.Columns("B").Select
Selection.AutoFilter Field:=1, Criteria1:="info"
Selection.EntireRow.Hidden = True

but ALL rows get hidden. What is wrong?


--
Turquoise_dax
------------------------------------------------------------------------
Turquoise_dax's Profile: http://www.excelforum.com/member.php...o&userid=35185
View this thread: http://www.excelforum.com/showthread...hreadid=553626

  #4   Report Post  
Posted to microsoft.public.excel.misc
Turquoise_dax
 
Posts: n/a
Default How to program a macro to hide rows with conditionnal formating


I need to use a macro, because it is to be linked to a button.

I tried this code:

ActiveSheet.Columns("B").Select
Selection.AutoFilter Field:=1, Criteria1:="info"
Selection.EntireRow.Hidden = True

but ALL rows get hidden. What is wrong?


--
Turquoise_dax
------------------------------------------------------------------------
Turquoise_dax's Profile: http://www.excelforum.com/member.php...o&userid=35185
View this thread: http://www.excelforum.com/showthread...hreadid=553626

  #5   Report Post  
Posted to microsoft.public.excel.misc
CLR
 
Posts: n/a
Default How to program a macro to hide rows with conditionnal formatin

Try this one, it's a toggle on/off

Sub HideInfoRows()
Range("A2").Select
If ActiveSheet.AutoFilterMode = False Then
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="<*info*", Operator:=xlAnd
Else
Selection.AutoFilter
End If
End Sub

hth
Vaya con Dios,
Chuck, CABGx3



"Turquoise_dax" wrote:


I need to use a macro, because it is to be linked to a button.

I tried this code:

ActiveSheet.Columns("B").Select
Selection.AutoFilter Field:=1, Criteria1:="info"
Selection.EntireRow.Hidden = True

but ALL rows get hidden. What is wrong?


--
Turquoise_dax
------------------------------------------------------------------------
Turquoise_dax's Profile: http://www.excelforum.com/member.php...o&userid=35185
View this thread: http://www.excelforum.com/showthread...hreadid=553626




  #6   Report Post  
Posted to microsoft.public.excel.misc
DCSwearingen
 
Posts: n/a
Default How to program a macro to hide rows with conditionnal formating


The following will enable you to limit your macro loop to only the
active range, without having to always edit for any inserted rows.

Option Explicit
'--------------
Private Function FindLastCell()
Dim lCell As String
Range("A1").Select
lCell = ActiveCell.SpecialCells(xlLastCell).Address
FindLastCell = lCell
End Function
'--------------

Assuming you are looking for the word "Info" in column B (2)
'--------------
Sub HideRows()
Dim dSearch As String, lRow As Long, rNum As Long
Application.ScreenUpdating = False
Cells.EntireRow.Hidden = False
dSearch = "Info"
lRow = FindLastRow()
For rNum = 1 To lRow
If Cells(rNum, 2).Value = dSearch Then 'Column B is Col 2
Rows(rNum).EntireRow.Hidden = True
End If
Next
Application.ScreenUpdating = True
End Sub
'--------------


--
DCSwearingen

Getting old, but love computers.
------------------------------------------------------------------------
DCSwearingen's Profile: http://www.excelforum.com/member.php...o&userid=21506
View this thread: http://www.excelforum.com/showthread...hreadid=553626

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
resetting last cell jagdish.eashwar Excel Discussion (Misc queries) 11 March 31st 06 02:06 AM
Removing Rows for Printing Frick Excel Worksheet Functions 20 March 10th 06 10:53 PM
Three tables on one worksheet, need to hide rows Chiku Excel Discussion (Misc queries) 12 December 6th 05 10:47 PM
Macro to delete rows with same data Connie Martin Excel Worksheet Functions 12 November 22nd 05 01:18 PM
macro to hide rows if cell is blank Shooter Excel Worksheet Functions 3 September 28th 05 10:55 PM


All times are GMT +1. The time now is 02:16 PM.

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"