将范围的可见单元格添加到数组 [英] Add visible cells of a range to array

查看:73
本文介绍了将范围的可见单元格添加到数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将范围的可见单元格的值放入数组中.

I am trying to get the values of the visible cells of a range into an array.

我的代码使数组携带值,直到第一个不可见的单元格停止.

My code makes the array carry the values until the first non visible cell then stops.

Public Function ListeMaschinen() As Variant

Dim Auswahl As Range

With Sheets("qry_TechnischesDatenblatt")
Set Auswahl = .Range(.Range("A2:B2"), .Range("A2:B2").End(xlDown)).SpecialCells(xlCellTypeVisible)
End With

ListeMaschinen = Auswahl

End Function

如果我选择范围,它会显示我想要标记的所有单元格.

If I select the range it shows all the cells I want marked.

Auswahl.Select

推荐答案

这里我已将范围单元格添加到数组中.

Here I have added the range cells to an array.

Sub examp()
Dim rng As Range, cll As Range, i As Integer, a(100) As Variant
Set rng = Range(Range("A2:B2"), Range("A2:B2").End(xlDown)).SpecialCells(xlCellTypeVisible)
i = 0
For Each cll In rng
a(i) = cll.Value
i = i + 1
Next
End Sub

这篇关于将范围的可见单元格添加到数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆