Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Macro to Filter on active cell within autofilter

I have a spreadsheet that I already have autofilter activated on, what
I would like to do is have a macro that I can pop on my toolbar that
will filter the file based on the active cell contents, I had a macro
that did this in previous verison of excel but I somehow lost it during
migration to excel 2003 & cannot recreate it


Can anybody guide me on this

Appreciate it

Robin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Macro to Filter on active cell within autofilter

Robin,

This is written with the assumption that you have only one contiguous data table filtered:

Sub FilterBasedOnActiveCellContents()
ActiveCell.CurrentRegion.AutoFilter _
Field:=ActiveCell.Column - ActiveCell.CurrentRegion.Cells(1).Column + 1, _
Criteria1:=ActiveCell.Value
End Sub

HTH,
Bernie
MS Excel MVP


"Cheekyaardvark" wrote in message
ups.com...
I have a spreadsheet that I already have autofilter activated on, what
I would like to do is have a macro that I can pop on my toolbar that
will filter the file based on the active cell contents, I had a macro
that did this in previous verison of excel but I somehow lost it during
migration to excel 2003 & cannot recreate it


Can anybody guide me on this

Appreciate it

Robin



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Macro to Filter on active cell within autofilter

Thanks Bernie

Does this macro define the current cell as the active cell... the macro
only works the first time & seems to capture the value of that first
run for it to do subsequent filters on... for example if I run this on
a cell with 0.00 value & then move to a different column it attempts to
filter on 0.00 not the new active cell
What I was trying to get to was a position where I can filter on a
value in one column & then move to another column & further filter on
that to "home in" on fewer & fewer rows,
I want to run subsequent runs of the same macro but with the criteria
defined in the active cell

Thanks again for the assistance...

Robin


Bernie Deitrick wrote:
Robin,

This is written with the assumption that you have only one contiguous data table filtered:

Sub FilterBasedOnActiveCellContents()
ActiveCell.CurrentRegion.AutoFilter _
Field:=ActiveCell.Column - ActiveCell.CurrentRegion.Cells(1).Column + 1, _
Criteria1:=ActiveCell.Value
End Sub

HTH,
Bernie
MS Excel MVP


"Cheekyaardvark" wrote in message
ups.com...
I have a spreadsheet that I already have autofilter activated on, what
I would like to do is have a macro that I can pop on my toolbar that
will filter the file based on the active cell contents, I had a macro
that did this in previous verison of excel but I somehow lost it during
migration to excel 2003 & cannot recreate it


Can anybody guide me on this

Appreciate it

Robin


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Macro to Filter on active cell within autofilter

Robin,

The first macro will filter based on the first value, then the next cell value, then the next. But
you can use this new macro when you want to clear the original filtering before filtering on one
column only.

Sub ReFilterBasedOnActiveCellContents()
If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData
ActiveCell.CurrentRegion.AutoFilter _
Field:=ActiveCell.Column - ActiveCell.CurrentRegion.Cells(1).Column + 1, _
Criteria1:=ActiveCell.Value
End Sub

It wasn't clear from your post which type of filtering you prefered.

HTH,
Bernie
MS Excel MVP


"Cheekyaardvark" wrote in message
ps.com...
Thanks Bernie

Does this macro define the current cell as the active cell... the macro
only works the first time & seems to capture the value of that first
run for it to do subsequent filters on... for example if I run this on
a cell with 0.00 value & then move to a different column it attempts to
filter on 0.00 not the new active cell
What I was trying to get to was a position where I can filter on a
value in one column & then move to another column & further filter on
that to "home in" on fewer & fewer rows,
I want to run subsequent runs of the same macro but with the criteria
defined in the active cell

Thanks again for the assistance...

Robin


Bernie Deitrick wrote:
Robin,

This is written with the assumption that you have only one contiguous data table filtered:

Sub FilterBasedOnActiveCellContents()
ActiveCell.CurrentRegion.AutoFilter _
Field:=ActiveCell.Column - ActiveCell.CurrentRegion.Cells(1).Column + 1, _
Criteria1:=ActiveCell.Value
End Sub

HTH,
Bernie
MS Excel MVP


"Cheekyaardvark" wrote in message
ups.com...
I have a spreadsheet that I already have autofilter activated on, what
I would like to do is have a macro that I can pop on my toolbar that
will filter the file based on the active cell contents, I had a macro
that did this in previous verison of excel but I somehow lost it during
migration to excel 2003 & cannot recreate it


Can anybody guide me on this

Appreciate it

Robin




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Macro to Filter on active cell within autofilter

Bernie...

Sorry for being unclear...

This macro still seems to hold the value of the initial filter.. I am
not explaining very well, I have sent you a sample sheet, which
hopefully helps you to help me

Robin


Bernie Deitrick wrote:
Robin,

The first macro will filter based on the first value, then the next cell value, then the next. But
you can use this new macro when you want to clear the original filtering before filtering on one
column only.

Sub ReFilterBasedOnActiveCellContents()
If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData
ActiveCell.CurrentRegion.AutoFilter _
Field:=ActiveCell.Column - ActiveCell.CurrentRegion.Cells(1).Column + 1, _
Criteria1:=ActiveCell.Value
End Sub

It wasn't clear from your post which type of filtering you prefered.

HTH,
Bernie
MS Excel MVP


"Cheekyaardvark" wrote in message
ps.com...
Thanks Bernie

Does this macro define the current cell as the active cell... the macro
only works the first time & seems to capture the value of that first
run for it to do subsequent filters on... for example if I run this on
a cell with 0.00 value & then move to a different column it attempts to
filter on 0.00 not the new active cell
What I was trying to get to was a position where I can filter on a
value in one column & then move to another column & further filter on
that to "home in" on fewer & fewer rows,
I want to run subsequent runs of the same macro but with the criteria
defined in the active cell

Thanks again for the assistance...

Robin


Bernie Deitrick wrote:
Robin,

This is written with the assumption that you have only one contiguous data table filtered:

Sub FilterBasedOnActiveCellContents()
ActiveCell.CurrentRegion.AutoFilter _
Field:=ActiveCell.Column - ActiveCell.CurrentRegion.Cells(1).Column + 1, _
Criteria1:=ActiveCell.Value
End Sub

HTH,
Bernie
MS Excel MVP


"Cheekyaardvark" wrote in message
ups.com...
I have a spreadsheet that I already have autofilter activated on, what
I would like to do is have a macro that I can pop on my toolbar that
will filter the file based on the active cell contents, I had a macro
that did this in previous verison of excel but I somehow lost it during
migration to excel 2003 & cannot recreate it


Can anybody guide me on this

Appreciate it

Robin





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Macro to Filter on active cell within autofilter

Robin,

I'll be on the lookout - but no file yet....

Bernie
MS Excel MVP


"Cheekyaardvark" wrote in message
ups.com...
Bernie...

Sorry for being unclear...

This macro still seems to hold the value of the initial filter.. I am
not explaining very well, I have sent you a sample sheet, which
hopefully helps you to help me

Robin


Bernie Deitrick wrote:
Robin,

The first macro will filter based on the first value, then the next cell value, then the next.
But
you can use this new macro when you want to clear the original filtering before filtering on one
column only.

Sub ReFilterBasedOnActiveCellContents()
If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData
ActiveCell.CurrentRegion.AutoFilter _
Field:=ActiveCell.Column - ActiveCell.CurrentRegion.Cells(1).Column + 1, _
Criteria1:=ActiveCell.Value
End Sub

It wasn't clear from your post which type of filtering you prefered.

HTH,
Bernie
MS Excel MVP


"Cheekyaardvark" wrote in message
ps.com...
Thanks Bernie

Does this macro define the current cell as the active cell... the macro
only works the first time & seems to capture the value of that first
run for it to do subsequent filters on... for example if I run this on
a cell with 0.00 value & then move to a different column it attempts to
filter on 0.00 not the new active cell
What I was trying to get to was a position where I can filter on a
value in one column & then move to another column & further filter on
that to "home in" on fewer & fewer rows,
I want to run subsequent runs of the same macro but with the criteria
defined in the active cell

Thanks again for the assistance...

Robin


Bernie Deitrick wrote:
Robin,

This is written with the assumption that you have only one contiguous data table filtered:

Sub FilterBasedOnActiveCellContents()
ActiveCell.CurrentRegion.AutoFilter _
Field:=ActiveCell.Column - ActiveCell.CurrentRegion.Cells(1).Column + 1, _
Criteria1:=ActiveCell.Value
End Sub

HTH,
Bernie
MS Excel MVP


"Cheekyaardvark" wrote in message
ups.com...
I have a spreadsheet that I already have autofilter activated on, what
I would like to do is have a macro that I can pop on my toolbar that
will filter the file based on the active cell contents, I had a macro
that did this in previous verison of excel but I somehow lost it during
migration to excel 2003 & cannot recreate it


Can anybody guide me on this

Appreciate it

Robin





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Macro to Filter on active cell within autofilter

The solution to this problem was

Sub FilterBasedOnActiveCellContents()
ActiveCell.CurrentRegion.AutoFilter _
Field:=ActiveCell.Column - ActiveCell.CurrentRegion.Cells(1).Column + 1, _
Criteria1:=ActiveCell.Text
End Sub

It turns out that the values being filtered were numbers, with different formatting, and filtering
is based on formatted values, not the underlying values.

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Robin,

I'll be on the lookout - but no file yet....

Bernie
MS Excel MVP


"Cheekyaardvark" wrote in message
ups.com...
Bernie...

Sorry for being unclear...

This macro still seems to hold the value of the initial filter.. I am
not explaining very well, I have sent you a sample sheet, which
hopefully helps you to help me

Robin


Bernie Deitrick wrote:
Robin,

The first macro will filter based on the first value, then the next cell value, then the next.
But
you can use this new macro when you want to clear the original filtering before filtering on one
column only.

Sub ReFilterBasedOnActiveCellContents()
If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData
ActiveCell.CurrentRegion.AutoFilter _
Field:=ActiveCell.Column - ActiveCell.CurrentRegion.Cells(1).Column + 1, _
Criteria1:=ActiveCell.Value
End Sub

It wasn't clear from your post which type of filtering you prefered.

HTH,
Bernie
MS Excel MVP


"Cheekyaardvark" wrote in message
ps.com...
Thanks Bernie

Does this macro define the current cell as the active cell... the macro
only works the first time & seems to capture the value of that first
run for it to do subsequent filters on... for example if I run this on
a cell with 0.00 value & then move to a different column it attempts to
filter on 0.00 not the new active cell
What I was trying to get to was a position where I can filter on a
value in one column & then move to another column & further filter on
that to "home in" on fewer & fewer rows,
I want to run subsequent runs of the same macro but with the criteria
defined in the active cell

Thanks again for the assistance...

Robin


Bernie Deitrick wrote:
Robin,

This is written with the assumption that you have only one contiguous data table filtered:

Sub FilterBasedOnActiveCellContents()
ActiveCell.CurrentRegion.AutoFilter _
Field:=ActiveCell.Column - ActiveCell.CurrentRegion.Cells(1).Column + 1, _
Criteria1:=ActiveCell.Value
End Sub

HTH,
Bernie
MS Excel MVP


"Cheekyaardvark" wrote in message
ups.com...
I have a spreadsheet that I already have autofilter activated on, what
I would like to do is have a macro that I can pop on my toolbar that
will filter the file based on the active cell contents, I had a macro
that did this in previous verison of excel but I somehow lost it during
migration to excel 2003 & cannot recreate it


Can anybody guide me on this

Appreciate it

Robin







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
How do I filter for a blank cell, using custom autofilter Bee Jay Are Es Ay Excel Discussion (Misc queries) 3 April 3rd 23 07:00 PM
Active Cell in Auto Filter Michael Link Excel Discussion (Misc queries) 1 August 1st 06 04:27 PM
Active Cell to be used as filter... Darin Kramer Excel Programming 2 July 21st 06 03:18 PM
Macro to paste in the active cell the contents of a cell from another file?? LarryB Excel Programming 3 June 12th 06 06:37 PM
autofilter on a not-active sheet Peter[_21_] Excel Programming 2 January 15th 05 12:33 PM


All times are GMT +1. The time now is 11:23 AM.

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"