View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
JRForm JRForm is offline
external usenet poster
 
Posts: 130
Default Using a function to hide rows

Ryan,

Let me see if I understand your request. You are searching a column for a
specific value and when/if you find it you want to hide the row. Also you
want to hide the rows that are associated with it. Is this correct?



"Ryan" wrote:

Thanks, that works great but doesn't really accomplish what I'm trying to do.
I don't want the sheet to change every time <Enter the value you are
searching for is inputted, only when the value of a certain cell is changed.
Basically, what I have is a row with validated cell in in and 8 hidden rows
immediately following. The validated cell has a list of values 1-8 and
depending on what value you choose from this list, that many rows below hide
or unhide. Any change you have words on wisdom as how to accomplish this?

Ryan

"JRForm" wrote:

Ryan,

Put this code in the Thisworkbook module.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target = <Enter the value you are searching for Then
Range(Target.Address).Select
Selection.EntireRow.Hidden = True
End If

"Ryan" wrote:

First and foremost, any suggestions would be greatly appreciated!

I'm trying to use a function to hide a row or rows based upon the results of
a given cell. I would use a sub but I need it to update the number of hidden
cells each time the value in the cell changes. So far I've tried something
like:

Function Hide_Rows(Input_Cell as Range)
Dim InputRow = InputCell.Row
If InputCell = (some number) Then
Rows(InputRow+1).Hidden = True
End If....


The function compiles fine, but the row doesn't get hidden when the function
is implemented. Any ideas, suggestions, comments on how to fix this? Thanks.

Ryan