Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Printing Headers using Criteria chosen from AutoFilter

Can I create a way to have the headers of a report change by the criteria
chosen from an Auto Filter Field?

I have a worksheet with a generic print button for users. I would like to
have the header change depending on which A1 Field the user chose; i.e.,
Utah, Montana, California, etc.

Is it possible.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default Printing Headers using Criteria chosen from AutoFilter

Sondra

The basic syntax would be

Sheet1.PageSetup.CenterHeader = Sheet1.AutoFilter.Filters(1).Criteria1

I think Filters(1) will refer to the first column of your fitlered range, so
it should work for A1 in your case. This will show things like

=Utah for equal to Utah
=*Utah for ends with Utah
=*Utah* for contains Utah
<Utah for does not equal Utah

You might want to get all those operators out of there. Here's a procedure
that does that

Dim sCrit As String
Dim vOpers As Variant
Dim i As Long

vOpers = Array("=", "*", "<", "")

sCrit = Sheet4.AutoFilter.Filters(1).Criteria1
For i = LBound(vOpers) To UBound(vOpers)
sCrit = Replace(sCrit, vOpers(i), "")
Next i
Sheet4.PageSetup.CenterHeader = sCrit

The results may be misleading though. If someone chooses 'does not equal
Utah' the header will say 'Utah'. It will also remove any equal signs, etc.
from within the text, but that doesn't sound like it will be a problem for
you. Finally, it doesn't make sure there's a filter, so you might want to
check the FitlerMode property of the sheet first.

--
Dick Kusleika
MS MVP - Excel
www.dailydoseofexcel.com
Sondra wrote:
Can I create a way to have the headers of a report change by the
criteria chosen from an Auto Filter Field?

I have a worksheet with a generic print button for users. I would
like to have the header change depending on which A1 Field the user
chose; i.e., Utah, Montana, California, etc.

Is it possible.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default Printing Headers using Criteria chosen from AutoFilter


The results may be misleading though. If someone chooses 'does not
equal Utah' the header will say 'Utah'. It will also remove any
equal signs, etc. from within the text, but that doesn't sound like
it will be a problem for you. Finally, it doesn't make sure there's
a filter, so you might want to check the FitlerMode property of the
sheet first.


Make that AutoFilterMode, not FilterMode. And you should also check

Sheet1.AutoFilter.Filters(1).On

to ensure that filter was set on that column.

--
Dick Kusleika
MS MVP - Excel
www.dailydoseofexcel.com


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
Display Chosen Autofilter Value LP Excel Discussion (Misc queries) 2 April 28th 10 02:44 AM
Footers/Headers Not Printing Connie New Users to Excel 2 September 17th 09 05:50 PM
How to keep Column headers with Autofilter & Freeze Panes Rich D Excel Discussion (Misc queries) 8 July 3rd 08 10:02 PM
Printing Headers [email protected] Excel Discussion (Misc queries) 2 March 26th 05 12:12 AM
Printing Headers JRobinP Excel Discussion (Misc queries) 2 March 25th 05 07:19 PM


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