LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Hiding/Unhiding rows

I have a button that when the user presses the button the program will search
an ordered column for values equal to 0 and hide the rows that has values
equal to zero. If the rows already are hidden then they shall be revealed by
pressing the button. My code is:

Sub showHideButton_Klicka()
Dim relativCell As Range
Dim i As Integer, j As Integer, k As Integer
Dim blnFirstFound As Boolean, blnLastFound As Boolean, blnIsHidden As
Boolean

Set relativCell = Worksheets("Beräkning").Cells.Find("Rel.",
LookIn:=xlValues)
'here I start to look for the first and last cell that is equal to zero.
Do Until IsEmpty(relativCell.Offset(i, 0)) = True Or blnLastFound = True
If blnFirstFound = False Then
If relativCell.Offset(i, 0) = 0 Then
blnFirstFound = True
k = i
Else: End If
End If

If blnFirstFound = True And blnLastFound = False Then
j = i
If relativCell.Offset(j + 1, 0) < 0 Then
blnLastFound = True
Else: End If
Else: End If

i = i + 1 'längst ner i listan
Loop
'here i have stopped looking for the last cell

'here I select the rows that have cells that are equal to zero
startRow = relativCell.Offset(k, 0).Row
endRow = relativCell.Offset(j, 0).Row
Rows("" & startRow & ":" & endRow & "").Select
'here i want to hide the rows
If blnIsHidden = False Then
Selection.EntireRow.Hidden = True 'gömmer rader
Else

End Sub

my problem is that how do you write the code for unhiding the values?
i know you can write:
Selection.EntireRow.Hidden = False
but will this work? I dont want to search for zeros when unhiding. but how
do you solve this? i though about using a boolean to check if the rows are
hidden or not but I do not know how to proceed. please help me if you can!
thanks!

 
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
hiding/unhiding rows Art Excel Worksheet Functions 1 March 16th 10 05:00 PM
Hiding/Unhiding Rows Automatically Brad Resnick Excel Worksheet Functions 1 February 23rd 10 11:29 PM
hidden rows but not from hiding/unhiding? Reeder88 Excel Discussion (Misc queries) 1 March 12th 08 06:14 PM
unhiding and hiding rows Paul_of_Abingdon[_2_] Excel Discussion (Misc queries) 2 March 6th 08 03:22 PM
Hiding/unhiding rows Matheus Excel Discussion (Misc queries) 2 November 11th 07 11:20 PM


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