View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
RyanH RyanH is offline
external usenet poster
 
Posts: 586
Default Hide rows within range if B? = X

I don't believe there is a Forms Control Toggle Button, I could be wrong
though. If you only have one control on the worksheet the ActiveX Toggle
Button will give you more flexibilty and won't affect performance. I think
performance is affected when you have multiple ActiveX controls.

Add a Toggle Button to whatever worksheet you are trying to hide the rows.
Then place this code in the Toggle Buttons Click Event which should be in the
worksheets module.

Option Explicit

Private Sub ToggleButton1_Click()

Dim cell As Range

Application.ScreenUpdating = False

If ToggleButton1 = True Then
For Each cell In Range("T_Box_R")
If cell.Value = "*" Then
cell.EntireRow.Hidden = True
End If
Next cell
Else
Range("T_Box_R").Rows.EntireRow.Hidden = False
End If

Application.ScreenUpdating = True

End Sub

Note: If the toggle button happens to be located in the rows you are
hidding you may want to set the Format Control to Don't Size or Move with
Cells.
--
Cheers,
Ryan


"BEEJAY" wrote:

Sorry about my tardy response.
I found I had something to learn about "buttons", as well.
Based on conclusions made from info in my books and in user groups, I
decided to use a "forms" button rather than the active x buttons.

I used Mike's code and it works great (AND fast)
I do want to work with Ryans and see what modifications it needs to work
with forms buttons.

Don's code is going to be a major challenge. I want to work on it as well,
time permitting. It will have to be adjusted to work on a specified RANGE - I
understand it works on the complete active ws, as it is written.

Thanks so much for the varied input. As always, much appreciated.

"Don Guillett" wrote:

Here is a sub that will unhide if hidden or hide if * for the ACTIVE column
from row 3 to the last row in the column.
It probably could be re-written to make the x/* UN necessary by looking
directly at col E.

Modify to suit

Sub hiderowsif()
mc = ActiveCell.Column
lr = Cells(Rows.Count, mc).End(xlUp).Row
rc = Range(Cells(1, 1), Cells(lr, mc)). _
SpecialCells(xlCellTypeVisible).Count
If rc < lr Then
Rows.Hidden = False
Else
For i = lr To 3 Step -1
If Cells(i, mc) = "*" Then Rows(i).Hidden = True
Next i
End If
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"BEEJAY" wrote in message
...
Greetings all:

Situation:
Formula in each cell in column B:
Cell B? has a "x" if no quantity entered in cell E?
Cell B? has an "*" if a quantity IS entered in cell E?

Range: B788 thru B846
Range Named: T_Box_R

Looking for (High Speed) code to Hide all rows with "*" in column B,
WITHIN
the Specified Named Range ONLY.

The code will be operated with a toggle button that will:
1: Activate the hide code
2: Unhide all hidden rows within the specified Named Range

There will be numerous incidents of this used within one Worksheet, each
with its own toggle, operating on a different Named Range.

All help gratefully received!!