Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Named Range Change Based On AutoFilter


I'm creating an excel sheet and I need to use the autofilter on my list
based on another cell.

For example, if A1 is L, then the AutoFilter filters the results of the
first column for L types.

Then I need that selection of L values from the AutoFilter to be a
named range.

Thanks.


--
SanctifiedRock
------------------------------------------------------------------------
SanctifiedRock's Profile: http://www.excelforum.com/member.php...o&userid=34485
View this thread: http://www.excelforum.com/showthread...hreadid=542474

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Named Range Change Based On AutoFilter

assume the upper left corner of your data is in B9, then:

Sub ABC()
Dim rng As Range, rng1 As Range
Range("B9").CurrentRegion.AutoFilter _
Field:=1, Criteria1:=Range("A1").Value
Set rng = ActiveSheet.AutoFilter.Range
If rng.Columns(1).SpecialCells(xlVisible).Count 1 Then
With rng.Columns(1)
Set rng1 = .Offset(1, 0).Resize( _
.Rows.Count - 1, 1).SpecialCells(xlVisible)
rng1.Name = Range("A1").Value
End With
End If


End Sub

--
Regards,
Tom Ogilvy


"SanctifiedRock" wrote:


I'm creating an excel sheet and I need to use the autofilter on my list
based on another cell.

For example, if A1 is L, then the AutoFilter filters the results of the
first column for L types.

Then I need that selection of L values from the AutoFilter to be a
named range.

Thanks.


--
SanctifiedRock
------------------------------------------------------------------------
SanctifiedRock's Profile: http://www.excelforum.com/member.php...o&userid=34485
View this thread: http://www.excelforum.com/showthread...hreadid=542474


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Named Range Change Based On AutoFilter


Thanks, but the line in red seems to be causing an error.

Sub ABC()
Dim rng As Range, rng1 As Range
Range("A12").CurrentRegion.AutoFilter _
Field:=1, Criteria1:=Range("A11").Value
Set rng = ActiveSheet.AutoFilter.Range
If rng.Columns(1).SpecialCells(xlVisible).Count 1 Then
With rng.Columns(1)
Set rng1 = .Offset(1, 0).Resize( _
..Rows.Count - 1, 1).SpecialCells(xlVisible)
rng1.Name = Range("A11").Value
End With
End If


End Sub


--
SanctifiedRock
------------------------------------------------------------------------
SanctifiedRock's Profile: http://www.excelforum.com/member.php...o&userid=34485
View this thread: http://www.excelforum.com/showthread...hreadid=542474

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Named Range Change Based On AutoFilter

I can't see any line in red, but your filter area should be separated on all
sides by a blank row/column. so having a value in A11 and trying to start
your filter in A12 will cause a problem with using CurrentRegion. either
Isolate your data or specify exactly what range you want to apply the filter
to. with isolated data the code ran fine for me.

--
Regards,
Tom Ogilvy


"SanctifiedRock" wrote:


Thanks, but the line in red seems to be causing an error.

Sub ABC()
Dim rng As Range, rng1 As Range
Range("A12").CurrentRegion.AutoFilter _
Field:=1, Criteria1:=Range("A11").Value
Set rng = ActiveSheet.AutoFilter.Range
If rng.Columns(1).SpecialCells(xlVisible).Count 1 Then
With rng.Columns(1)
Set rng1 = .Offset(1, 0).Resize( _
.Rows.Count - 1, 1).SpecialCells(xlVisible)
rng1.Name = Range("A11").Value
End With
End If


End Sub


--
SanctifiedRock
------------------------------------------------------------------------
SanctifiedRock's Profile: http://www.excelforum.com/member.php...o&userid=34485
View this thread: http://www.excelforum.com/showthread...hreadid=542474


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
Q: Named range based on cell value? Mark Excel Discussion (Misc queries) 3 November 13th 07 11:06 PM
Referencing a named range based upon Range name entry in cell Barb Reinhardt Excel Worksheet Functions 14 June 20th 07 07:19 PM
inserting a named range into new cells based on a named cell Peter S. Excel Discussion (Misc queries) 1 June 4th 06 03:53 AM
How Do I Do an Exclude Filter based on a Named Range? Dawg House Inc Excel Worksheet Functions 8 April 11th 06 02:49 AM
Define a range based on another named range Basil Excel Worksheet Functions 2 February 21st 05 01:47 PM


All times are GMT +1. The time now is 02:53 AM.

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"