Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Hidden rows Database Filter

I've got a 50,000-row Excel database with various controls that hide rows
for various reasons. Now I want to summarize the non-hidden rows in various
ways. Unfortunately, SUBTOTAL, DSUM, and similar functions rely directly or
indirectly on a Criteria range.

Logically, I have two choices. I could write custom SUM, COUNT, and other
such functions, which would apply only to the unhidden rows. Alternatively,
I could mark each row somehow so that a simple Criteria could recognize the
unhidden rows, filter the data, and allow me to use SUBTOTAL, DSUM, and the
like.

Any of these alternatives would be possible, of course. But they all require
many seconds to perform. This creates a very sluggish user interface.

Can anyone suggest a speedy way to transform a database with hidden rows
into a filtered database with the same rows hidden?

Thanks.

Charley


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Hidden rows Database Filter

Sub ConvertToFilter()
Dim rng As Range, rng1 As Range
Dim rng2 As Range, rng3 As Range
Dim col As Long
Set rng = Range("A1").CurrentRegion
col = rng.Columns(rng.Columns.Count).Column
Set rng1 = rng
Set rng1 = rng1.Offset(1, 0).Resize(rng.Rows.Count - 1, 1)
Set rng2 = Intersect(rng1.EntireRow, Cells(1, col + 1).EntireColumn)
Set rng3 = rng2.SpecialCells(xlVisible)
rng2.Value = "Hide"
rng3.Value = "Show"
Cells(1, col + 1).Value = "Header"
Cells.Rows.Hidden = False
Set rng = rng.Resize(, rng.Columns.Count + 1)
rng.AutoFilter Field:=rng.Columns.Count, _
Criteria1:="Show"
End Sub

should impose an autofilter on your data - subtotal will work with this, but
not DSUM. However, subtotal should do what you want.

You could modify it to write a criteria range

header
Show

and set an advanced filter or use the Dfunctions.

--
Regards,
Tom Ogilvy



"Charley Kyd" wrote in message
...
I've got a 50,000-row Excel database with various controls that hide rows
for various reasons. Now I want to summarize the non-hidden rows in

various
ways. Unfortunately, SUBTOTAL, DSUM, and similar functions rely directly

or
indirectly on a Criteria range.

Logically, I have two choices. I could write custom SUM, COUNT, and other
such functions, which would apply only to the unhidden rows.

Alternatively,
I could mark each row somehow so that a simple Criteria could recognize

the
unhidden rows, filter the data, and allow me to use SUBTOTAL, DSUM, and

the
like.

Any of these alternatives would be possible, of course. But they all

require
many seconds to perform. This creates a very sluggish user interface.

Can anyone suggest a speedy way to transform a database with hidden rows
into a filtered database with the same rows hidden?

Thanks.

Charley




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Hidden rows Database Filter

Thanks, Tom! I forgot about SpecialCells(xlVisible)!

All the best,

Charley


"Tom Ogilvy" wrote in message
...
Sub ConvertToFilter()
Dim rng As Range, rng1 As Range
Dim rng2 As Range, rng3 As Range
Dim col As Long
Set rng = Range("A1").CurrentRegion
col = rng.Columns(rng.Columns.Count).Column
Set rng1 = rng
Set rng1 = rng1.Offset(1, 0).Resize(rng.Rows.Count - 1, 1)
Set rng2 = Intersect(rng1.EntireRow, Cells(1, col + 1).EntireColumn)
Set rng3 = rng2.SpecialCells(xlVisible)
rng2.Value = "Hide"
rng3.Value = "Show"
Cells(1, col + 1).Value = "Header"
Cells.Rows.Hidden = False
Set rng = rng.Resize(, rng.Columns.Count + 1)
rng.AutoFilter Field:=rng.Columns.Count, _
Criteria1:="Show"
End Sub

should impose an autofilter on your data - subtotal will work with this,

but
not DSUM. However, subtotal should do what you want.

You could modify it to write a criteria range

header
Show

and set an advanced filter or use the Dfunctions.

--
Regards,
Tom Ogilvy



"Charley Kyd" wrote in message
...
I've got a 50,000-row Excel database with various controls that hide

rows
for various reasons. Now I want to summarize the non-hidden rows in

various
ways. Unfortunately, SUBTOTAL, DSUM, and similar functions rely directly

or
indirectly on a Criteria range.

Logically, I have two choices. I could write custom SUM, COUNT, and

other
such functions, which would apply only to the unhidden rows.

Alternatively,
I could mark each row somehow so that a simple Criteria could recognize

the
unhidden rows, filter the data, and allow me to use SUBTOTAL, DSUM, and

the
like.

Any of these alternatives would be possible, of course. But they all

require
many seconds to perform. This creates a very sluggish user interface.

Can anyone suggest a speedy way to transform a database with hidden rows
into a filtered database with the same rows hidden?

Thanks.

Charley






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Hidden rows Database Filter

FYI...Here's my revised version. The only substantive change I made was to
adapt to a range that might have both filtered and hidden rows.

Charley
'====================
Sub ConvertToFilter()
Dim rngData As Range, rngFilter As Range, rngVisFilter As Range
Dim lCol As Long, rngInnerFilter As Range

Set rngData = ThisWorkbook.Names("AllData").RefersToRange

''Define the full column of x's (show) and blanks (hide)
Set rngFilter = ThisWorkbook.Names("datFilter").RefersToRange

''Define the inner range
Set rngInnerFilter = rngFilter.Offset(1,
0).Resize(rngFilter.Rows.Count - 2, 1)

''Get the hidden range, which could be from both filtering and manual
hiding
Set rngVisFilter = rngInnerFilter.SpecialCells(xlVisible)

''If the filter mode is on, then turn it off
If rngData.Worksheet.FilterMode Then rngData.AutoFilter

''Unhide any manually hidden rows
rngData.Rows.Hidden = False

''Erase the inner area of the entire column
rngInnerFilter.ClearContents

''Mark with an x only the data that had been visible
rngVisFilter.Value = "x"

''Expand rngData to include the column with the markers
Set rngData = rngData.Resize(, rngFilter.Column - rngData.Column + 1)

''Apply the filter
rngData.AutoFilter _
Field:=rngData.Columns.Count, _
Criteria1:="x"
End Sub

'===========================

"Tom Ogilvy" wrote in message
...
Sub ConvertToFilter()
Dim rng As Range, rng1 As Range
Dim rng2 As Range, rng3 As Range
Dim col As Long
Set rng = Range("A1").CurrentRegion
col = rng.Columns(rng.Columns.Count).Column
Set rng1 = rng
Set rng1 = rng1.Offset(1, 0).Resize(rng.Rows.Count - 1, 1)
Set rng2 = Intersect(rng1.EntireRow, Cells(1, col + 1).EntireColumn)
Set rng3 = rng2.SpecialCells(xlVisible)
rng2.Value = "Hide"
rng3.Value = "Show"
Cells(1, col + 1).Value = "Header"
Cells.Rows.Hidden = False
Set rng = rng.Resize(, rng.Columns.Count + 1)
rng.AutoFilter Field:=rng.Columns.Count, _
Criteria1:="Show"
End Sub

should impose an autofilter on your data - subtotal will work with this,

but
not DSUM. However, subtotal should do what you want.

You could modify it to write a criteria range

header
Show

and set an advanced filter or use the Dfunctions.

--
Regards,
Tom Ogilvy



"Charley Kyd" wrote in message
...
I've got a 50,000-row Excel database with various controls that hide

rows
for various reasons. Now I want to summarize the non-hidden rows in

various
ways. Unfortunately, SUBTOTAL, DSUM, and similar functions rely directly

or
indirectly on a Criteria range.

Logically, I have two choices. I could write custom SUM, COUNT, and

other
such functions, which would apply only to the unhidden rows.

Alternatively,
I could mark each row somehow so that a simple Criteria could recognize

the
unhidden rows, filter the data, and allow me to use SUBTOTAL, DSUM, and

the
like.

Any of these alternatives would be possible, of course. But they all

require
many seconds to perform. This creates a very sluggish user interface.

Can anyone suggest a speedy way to transform a database with hidden rows
into a filtered database with the same rows hidden?

Thanks.

Charley






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
hidden rows reappearing when using filter Betty Excel Worksheet Functions 2 February 12th 09 05:52 PM
hidden rows reappearing when using filter Betty Excel Worksheet Functions 0 February 12th 09 04:47 PM
Stop rows that i have hidden unhidding when i filter in excel APS Dave Excel Worksheet Functions 0 October 5th 07 11:06 AM
Hidden Rows with Auto-Filter Carol Excel Worksheet Functions 2 April 28th 07 03:34 PM
How to paste data over the hidden rows in a sheet with a filter hezemeftez Excel Discussion (Misc queries) 2 August 2nd 06 03:29 PM


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