AOB
Well-known Member
- Joined
- Dec 15, 2010
- Messages
- 669
- Office Version
- 365
- 2016
- 2013
- Platform
- Windows
Hi all,
Have been frustrated by this wee pickle for several hours now, so hoping somebody on this ever excellent forum might be able to point out the error of my ways!...
I'm trying to use an auto-filter to provide either a range of cells or an array of strings (I don't care which) from which to populate a combobox ("cbACC") drop-down list.
The code filters column A, determined by a separate, independent combo-box ("cbPool") and should then add the filtered values from column F to the list for "cbACC".
The problem is, by using the SpecialCells function, the header row is always included in that filtered range. And - unless one happens to choose the first item on "cbPool" - that range will always be non-contiguous. Meaning I can't offset/resize the filtered range down to just those cells containing the required list items. (Data is suitably sorted so the only element introducing non-contiguity is the header row)
I've tried populating the list with a range :
And cell-by-cell (excluding the header cell which is "ACC"):
But I can't define the appropriate range without including the header row, which means I can't have a contiguous range, which means my offsetting/resizing fails miserably.
Any suggestions would be very gratefully received!!
Thanks in advance
AOB
Have been frustrated by this wee pickle for several hours now, so hoping somebody on this ever excellent forum might be able to point out the error of my ways!...
I'm trying to use an auto-filter to provide either a range of cells or an array of strings (I don't care which) from which to populate a combobox ("cbACC") drop-down list.
The code filters column A, determined by a separate, independent combo-box ("cbPool") and should then add the filtered values from column F to the list for "cbACC".
The problem is, by using the SpecialCells function, the header row is always included in that filtered range. And - unless one happens to choose the first item on "cbPool" - that range will always be non-contiguous. Meaning I can't offset/resize the filtered range down to just those cells containing the required list items. (Data is suitably sorted so the only element introducing non-contiguity is the header row)
I've tried populating the list with a range :
Code:
With wsReference
[INDENT].AutoFilterMode = False
.Range(wsReference.Range("A1").CurrentRegion.Address).AutoFilter Field:=1, Criteria1:=cbPool.Value
[/INDENT][INDENT]Set rgACCs = .AutoFilter.Range.SpecialCells(xlCellTypeVisible).Offset(1, 5).Resize(.AutoFilter.Range.SpecialCells(xlCellTypeVisible).Rows.Count - 1, 1)
[/INDENT]End With
cbACC.List = rgACCs.Value
And cell-by-cell (excluding the header cell which is "ACC"):
Code:
With wsReference
[INDENT].AutoFilterMode = False
.Range(wsReference.Range("A1").CurrentRegion.Address).AutoFilter Field:=1, Criteria1:=cbPool.Value
For Each Cell In .AutoFilter.Range.SpecialCells(xlCellTypeVisible).Offset(, 5).Resize(, 1)
[INDENT]If Cell.Value <> "ACC" Then
[INDENT]cbACC.AddItem Cell.Value
[/INDENT]End If
[/INDENT]Next Cell
[/INDENT]End With
But I can't define the appropriate range without including the header row, which means I can't have a contiguous range, which means my offsetting/resizing fails miserably.
Any suggestions would be very gratefully received!!
Thanks in advance
AOB