您指定將打開自動篩選你的活動工作表宏。這將提供列標題,允許用戶過濾到感興趣的內容。 假設這種工作表中篩選的是你想要的,你可以使用的東西,像什麼:
Dim r As Range
'Note: set r to something useful, such as worksheet.Cells
Dim vis As Range
Set vis = r.SpecialCells(xlCellTypeVisible)
'now vis holds a special "Range" object referring to the visible cells.
'since (auto) filtering hides some cells, this vis range will help show only the cells that remain visible.
'the output of SpecialCells, you should assume holds a complex Range,
'which is composed of multiple Areas that are wrapped in one single Range object
'the separate areas help you distinguish the visible cells from the hidden cells
'fyi, various safety checks you can do: vis Is Range, vis Is Nothing
Dim a as Areas
Set a = r.Areas
Dim cr as Range
For Each cr in a
'cr refers to a single (i.e. normal and contiguous) area range
'where you can use cr.Row, cr.Column, cr.Rows.Count, cr.Columns.Count
Next
所以當你做過濾,可以使用SpecialCells(xlCellTypeVisible)揭示非隱藏的細胞,被表示爲具有包圍代表連續範圍的區域的範圍。
值填寫列表框一個窗體命名UReports這是列表中用戶窗體數組?或在一個組合框?或一個列表框?或者是其他東西? – 2012-07-19 16:28:14
我想要在Excel單元格中獲取的值是以列表的形式。並啓用了過濾器。我想在用戶表單列表框中添加這些值。 – IConfused 2012-07-19 16:32:32
在我給你的代碼之前,也許你想通過循環工作表中的列表來嘗試自己,然後使用'ListBox1.Add'來添加新項目? – 2012-07-19 16:39:56