C
CBartman
Would ultimately like to use array for userform combobox source.
Excel 2003
I seem to be having trouble with "non-consecutive" rows.
"Banging" my head. Any help would be appreciated. Thanks
Sub RangeFilter()
Dim w As Worksheet
Dim filterArray()
Dim currentFiltRange As String
Set w = Workbooks("My-Stuff.xls").Worksheets("My-Machines")
With w.ListObjects(1)
'filter the list (by column 5 data) based on userform textbox.text
currentFiltRange = .Range.AutoFilter(5, tbAcctNum.Text)
'sheet data is filtered correctly
MsgBox
w.ListObjects(1).DataBodyRange.SpecialCells(xlCellTypeVisible).Address
'Example result (based on selection)- $A$2:$P$4, $A$14:$P$32,
$A$36:$P$38
'visible results of filter. These addresses are correct.
ReDim filterArray(0 To f)
'An attempt to include only visible rows in an array
For f = 0 To .DataBodyRange.SpecialCells(xlCellTypeVisible).Rows.Count
'code to include ALL visible rows.
Next f
MsgBox f
'showing me number of visible rows for the above example as: 10
'incorrectly reporting number of visible rows (actual number of
rows: 13)
End With
End Sub
Excel 2003
I seem to be having trouble with "non-consecutive" rows.
"Banging" my head. Any help would be appreciated. Thanks
Sub RangeFilter()
Dim w As Worksheet
Dim filterArray()
Dim currentFiltRange As String
Set w = Workbooks("My-Stuff.xls").Worksheets("My-Machines")
With w.ListObjects(1)
'filter the list (by column 5 data) based on userform textbox.text
currentFiltRange = .Range.AutoFilter(5, tbAcctNum.Text)
'sheet data is filtered correctly
MsgBox
w.ListObjects(1).DataBodyRange.SpecialCells(xlCellTypeVisible).Address
'Example result (based on selection)- $A$2:$P$4, $A$14:$P$32,
$A$36:$P$38
'visible results of filter. These addresses are correct.
ReDim filterArray(0 To f)
'An attempt to include only visible rows in an array
For f = 0 To .DataBodyRange.SpecialCells(xlCellTypeVisible).Rows.Count
'code to include ALL visible rows.
Next f
MsgBox f
'showing me number of visible rows for the above example as: 10
'incorrectly reporting number of visible rows (actual number of
rows: 13)
End With
End Sub