Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I'm having trouble assigning an AutoFiltered Range of Data to a Range Object. Here is my Code: Sub PopulateValidationLists() Range("ClientCells").Select Dim theClientCode As String Dim FilteredClients As Range For Each Client In Range("ClientCells").Cells Range("CustomerSolutions").AutoFilter Field:=9, Criteria1:="" & Client.Value & "" Set FilteredClients = Selection.AutoFilter.Range.Offset(1, 0).Resize(Selection.AutoFilter.Range.Rows.Count - 1) Selection.AutoFilter.SpecialCells (xlCellTypeVisible) Next End Sub The problem lies with this line of code: Set FilteredClients = Selection.AutoFilter.Range.Offset(1, 0).Resize(Selection.AutoFilter.Range.Rows.Count - 1) Selection.AutoFilter.SpecialCells (xlCellTypeVisible) The error I receive is: Object Required Any ideas on how I can get around this? Thanks. Simon |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Simon
I hit a similar problem some long while back. I'm not sure this is the efficient way to do it, but it got me around the problem and i have persisted with it since. With wss having been set as the relevant sheet, and rng1 and rng2 dimmed as ranges Set rng1 = wss.AutoFilter.Range.Columns(1).Cells Set rng1 = rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1, 1) Set rng2 = rng1.SpecialCells(xlVisible) -- Regards Roger Govier "Simon" wrote in message ... Hi, I'm having trouble assigning an AutoFiltered Range of Data to a Range Object. Here is my Code: Sub PopulateValidationLists() Range("ClientCells").Select Dim theClientCode As String Dim FilteredClients As Range For Each Client In Range("ClientCells").Cells Range("CustomerSolutions").AutoFilter Field:=9, Criteria1:="" & Client.Value & "" Set FilteredClients = Selection.AutoFilter.Range.Offset(1, 0).Resize(Selection.AutoFilter.Range.Rows.Count - 1) Selection.AutoFilter.SpecialCells (xlCellTypeVisible) Next End Sub The problem lies with this line of code: Set FilteredClients = Selection.AutoFilter.Range.Offset(1, 0).Resize(Selection.AutoFilter.Range.Rows.Count - 1) Selection.AutoFilter.SpecialCells (xlCellTypeVisible) The error I receive is: Object Required Any ideas on how I can get around this? Thanks. Simon |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you filter out the first 100 rows of your data, and your filtered list has 10 values, then you
are trying to set FilteredClient to the visible cells of the first ten rows, all of which are hidden. Working with a filtered list, you should set a range to the full range (offset by 1, decreased by 1) and then use the visible cells on that Sub PopulateValidationLists2() Range("ClientCells").Select Dim theClientCode As String 'Not used Dim FilteredClients As Range Dim AllClients As Range Set AllClients = Range("CustomerSolutions").Offset(1,0).Resize(Rang e("CustomerSolutions").Rows.Count -1) For Each Client In Range("ClientCells").Cells Range("CustomerSolutions").AutoFilter Field:=9, Criteria1:=Client.Value Set FilteredClients =- AllClients.SpecialCells(xlCellTypeVisible) 'Do something here with FilteredClients Next End Sub HTH, Bernie MS Excel MVP "Simon" wrote in message ... Hi, I'm having trouble assigning an AutoFiltered Range of Data to a Range Object. Here is my Code: Sub PopulateValidationLists() Range("ClientCells").Select Dim theClientCode As String Dim FilteredClients As Range For Each Client In Range("ClientCells").Cells Range("CustomerSolutions").AutoFilter Field:=9, Criteria1:="" & Client.Value & "" Set FilteredClients = Selection.AutoFilter.Range.Offset(1, 0).Resize(Selection.AutoFilter.Range.Rows.Count - 1) Selection.AutoFilter.SpecialCells (xlCellTypeVisible) Next End Sub The problem lies with this line of code: Set FilteredClients = Selection.AutoFilter.Range.Offset(1, 0).Resize(Selection.AutoFilter.Range.Rows.Count - 1) Selection.AutoFilter.SpecialCells (xlCellTypeVisible) The error I receive is: Object Required Any ideas on how I can get around this? Thanks. Simon |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Bernie,
With this line of code: Set FilteredClients = AllClients.SpecialCells(xlCellTypeVisible) How do I change it so I only return the visible items in column 8? Thanks. Simon "Bernie Deitrick" wrote: If you filter out the first 100 rows of your data, and your filtered list has 10 values, then you are trying to set FilteredClient to the visible cells of the first ten rows, all of which are hidden. Working with a filtered list, you should set a range to the full range (offset by 1, decreased by 1) and then use the visible cells on that Sub PopulateValidationLists2() Range("ClientCells").Select Dim theClientCode As String 'Not used Dim FilteredClients As Range Dim AllClients As Range Set AllClients = Range("CustomerSolutions").Offset(1,0).Resize(Rang e("CustomerSolutions").Rows.Count -1) For Each Client In Range("ClientCells").Cells Range("CustomerSolutions").AutoFilter Field:=9, Criteria1:=Client.Value Set FilteredClients =- AllClients.SpecialCells(xlCellTypeVisible) 'Do something here with FilteredClients Next End Sub HTH, Bernie MS Excel MVP "Simon" wrote in message ... Hi, I'm having trouble assigning an AutoFiltered Range of Data to a Range Object. Here is my Code: Sub PopulateValidationLists() Range("ClientCells").Select Dim theClientCode As String Dim FilteredClients As Range For Each Client In Range("ClientCells").Cells Range("CustomerSolutions").AutoFilter Field:=9, Criteria1:="" & Client.Value & "" Set FilteredClients = Selection.AutoFilter.Range.Offset(1, 0).Resize(Selection.AutoFilter.Range.Rows.Count - 1) Selection.AutoFilter.SpecialCells (xlCellTypeVisible) Next End Sub The problem lies with this line of code: Set FilteredClients = Selection.AutoFilter.Range.Offset(1, 0).Resize(Selection.AutoFilter.Range.Rows.Count - 1) Selection.AutoFilter.SpecialCells (xlCellTypeVisible) The error I receive is: Object Required Any ideas on how I can get around this? Thanks. Simon |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Simon,
Try Set FilteredClients = Intersect(Range("H:H"), AllClients).SpecialCells(xlCellTypeVisible) OR Set FilteredClients = AllClients.Columns(8).SpecialCells(xlCellTypeVisib le) Depends, of course, on what you mean by column 8... ;-) HTH, Bernie MS Excel MVP "Simon" wrote in message ... Hi Bernie, With this line of code: Set FilteredClients = AllClients.SpecialCells(xlCellTypeVisible) How do I change it so I only return the visible items in column 8? Thanks. Simon "Bernie Deitrick" wrote: If you filter out the first 100 rows of your data, and your filtered list has 10 values, then you are trying to set FilteredClient to the visible cells of the first ten rows, all of which are hidden. Working with a filtered list, you should set a range to the full range (offset by 1, decreased by 1) and then use the visible cells on that Sub PopulateValidationLists2() Range("ClientCells").Select Dim theClientCode As String 'Not used Dim FilteredClients As Range Dim AllClients As Range Set AllClients = Range("CustomerSolutions").Offset(1,0).Resize(Rang e("CustomerSolutions").Rows.Count -1) For Each Client In Range("ClientCells").Cells Range("CustomerSolutions").AutoFilter Field:=9, Criteria1:=Client.Value Set FilteredClients =- AllClients.SpecialCells(xlCellTypeVisible) 'Do something here with FilteredClients Next End Sub HTH, Bernie MS Excel MVP "Simon" wrote in message ... Hi, I'm having trouble assigning an AutoFiltered Range of Data to a Range Object. Here is my Code: Sub PopulateValidationLists() Range("ClientCells").Select Dim theClientCode As String Dim FilteredClients As Range For Each Client In Range("ClientCells").Cells Range("CustomerSolutions").AutoFilter Field:=9, Criteria1:="" & Client.Value & "" Set FilteredClients = Selection.AutoFilter.Range.Offset(1, 0).Resize(Selection.AutoFilter.Range.Rows.Count - 1) Selection.AutoFilter.SpecialCells (xlCellTypeVisible) Next End Sub The problem lies with this line of code: Set FilteredClients = Selection.AutoFilter.Range.Offset(1, 0).Resize(Selection.AutoFilter.Range.Rows.Count - 1) Selection.AutoFilter.SpecialCells (xlCellTypeVisible) The error I receive is: Object Required Any ideas on how I can get around this? Thanks. Simon |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'd use something like:
Option Explicit Sub testme() Dim wks As Worksheet Dim VisRng As Range Dim Client As Range Dim ClientList As Range Set wks = ActiveSheet With wks 'remove any existing filter .AutoFilterMode = False Set ClientList = .Range("ClientCells") For Each Client In ClientList.Cells .Range("CustomerSolutions").AutoFilter Field:=9, _ Criteria1:="" & Client.Value & "" With .AutoFilter.Range If .Columns(1).Cells.SpecialCells(xlCellTypeVisible) _ .Count = 1 Then MsgBox "only the headers are visible for client: " _ & Client.Value Else 'resize to avoid the header 'and come down one row Set VisRng = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _ .Cells.SpecialCells(xlCellTypeVisible) MsgBox Client.Value & vbLf & VisRng.Address(0, 0) End If End With Next Client End With End Sub Simon wrote: Hi, I'm having trouble assigning an AutoFiltered Range of Data to a Range Object. Here is my Code: Sub PopulateValidationLists() Range("ClientCells").Select Dim theClientCode As String Dim FilteredClients As Range For Each Client In Range("ClientCells").Cells Range("CustomerSolutions").AutoFilter Field:=9, Criteria1:="" & Client.Value & "" Set FilteredClients = Selection.AutoFilter.Range.Offset(1, 0).Resize(Selection.AutoFilter.Range.Rows.Count - 1) Selection.AutoFilter.SpecialCells (xlCellTypeVisible) Next End Sub The problem lies with this line of code: Set FilteredClients = Selection.AutoFilter.Range.Offset(1, 0).Resize(Selection.AutoFilter.Range.Rows.Count - 1) Selection.AutoFilter.SpecialCells (xlCellTypeVisible) The error I receive is: Object Required Any ideas on how I can get around this? Thanks. Simon -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Top of AutoFiltered Range? | Excel Programming | |||
ASSIGNING THE VALUE TO A NAMED RANGE GIVING OBJECT DEFINED ERROR | Excel Programming | |||
Assigning an array to range object? | Excel Programming | |||
Assigning array to range inside Excel Object | Excel Programming | |||
Selecting cells which do not meet a formatting criteria, and assigning a Range object to these. | Excel Programming |