Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 91
Default Adv Filter with Ref Cell

I found some help to my problem here in the archives but am unable to
relocate it to ask for clarification. I am trying to use VBA to autofilter
based on a cell ref. This works withing the same sheet but I want the
refenced cell to come from a different sheet. Is there a way to change the
code, or do I have to put the VBA script in another sheet.

This is located on a sheet called "Planning" and works when the referenced
cell is on this same sheet.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$I$3" Then
Application.EnableEvents = False
If Target.Value = "" Then
ShowAllRecords
Else
Range("B4").CurrentRegion.AdvancedFilter _
Action:=xlFilterInPlace, CriteriaRange:= _
Range("K2:K3"), Unique:=False
End If
Application.EnableEvents = True
End If
End Sub

Where the Target.Address equals I3 of the Planner sheet, I want it to
reference cell B2 on the "Summary" sheet. Is there a way to do this? PS - I
know that this solution came to me by way of someone suggesting the website
contextures.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,979
Default Adv Filter with Ref Cell

The code should go on the module for the Summary sheet, which contains
the cell you're going to change. You can modify this to include the
correct location of your criteria range, and the top left cell of the
data on the planning sheet.

'====================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim wsPlan As Worksheet
Set wsPlan = Worksheets("Planning")

If Target.Address = "$B$2" Then
Application.EnableEvents = False
If Target.Value = "" Then
If wsPlan.FilterMode Then
wsPlan.ShowAllData
End If
Else
wsPlan.Range("B4").CurrentRegion.AdvancedFilter _
Action:=xlFilterInPlace, CriteriaRange:= _
Range("K2:K3"), Unique:=False
End If
Application.EnableEvents = True
End If
Set wsPlan = Nothing
End Sub
'================

JICDB wrote:
I found some help to my problem here in the archives but am unable to
relocate it to ask for clarification. I am trying to use VBA to autofilter
based on a cell ref. This works withing the same sheet but I want the
refenced cell to come from a different sheet. Is there a way to change the
code, or do I have to put the VBA script in another sheet.

This is located on a sheet called "Planning" and works when the referenced
cell is on this same sheet.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$I$3" Then
Application.EnableEvents = False
If Target.Value = "" Then
ShowAllRecords
Else
Range("B4").CurrentRegion.AdvancedFilter _
Action:=xlFilterInPlace, CriteriaRange:= _
Range("K2:K3"), Unique:=False
End If
Application.EnableEvents = True
End If
End Sub

Where the Target.Address equals I3 of the Planner sheet, I want it to
reference cell B2 on the "Summary" sheet. Is there a way to do this? PS - I
know that this solution came to me by way of someone suggesting the website
contextures.



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html

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
filter by a date in a cell Ken Excel Discussion (Misc queries) 2 August 10th 07 10:00 PM
how to filter through a colored cell which has no value??? Hus Excel Discussion (Misc queries) 3 August 5th 07 01:26 AM
filter by colored cell? tina Excel Worksheet Functions 3 February 12th 07 10:34 PM
Can I filter just one cell instead of the whole row? Some Dude Excel Discussion (Misc queries) 6 July 27th 06 08:25 PM
filter by colour cell Filtering on colour cell Excel Discussion (Misc queries) 2 February 12th 06 09:14 AM


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