我試圖訪問過濾列表中的C(數字):D(數字)值,但我似乎做錯了什麼,因爲MsgBox從不出現。如何訪問過濾列表中的範圍以檢索值? VBA
'Filter only numeric values
With MaterialListSheet
.AutoFilterMode = False
.Range("B1").AutoFilter Field:=1, Criteria1:="0*"
End With
Set rangeInventory = InventorySheet.Range("N1:N" & Rows.Count)
' I had Set rangeMaterialList = MaterialListSheet.Range("B1:B" & Rows.Count) in the beginning but I realized If I need C and D i'm only selecting B
Set rangeMaterialList = MaterialListSheet.Range("B1:F" & Rows.Count)
For Each CellML In rangeMaterialList.SpecialCells(xlCellTypeVisible)
BomCodesToSplit = CellML.Range("C" & Rows.Row & ":D" & Rows.Row).Values
MsgBox BomCodesToSplit
For Each CellI In rangeInventory.SpecialCells(xlCellTypeVisible)
Next CellI
Next CellML
試過,但沒有運氣:
BomCodesToSplit = MaterialListSheet.Range("C" & Rows.Row & ":D" & Rows.Row).Values
我想選擇
C1:D1
C2:D2
C3:D3
.
.
.
含義是這樣的,因此選擇它取決於循環索引
Cn:Dn
在其他一些編程語言我會使用循環的索引,但由於我是VBA新手,我不知道如何做到這一點。
如何實現這一目標?
'CellML.Row&CellML.Column'? – 2013-10-28 16:18:21
請理解我是VBA的新手,我不清楚這些概念。我如何爲每次迭代選擇C和D? – Splendonia
我覺得@mehow有解決方案的開始。我似乎記得,對於已過濾的範圍,您可能還需要遍歷範圍的'.Areas',然後迭代每個區域內的行/單元格。 –