我有一個包含這樣的數據的Excel文件中的隨機行:獲取一個表,其中列是一個已知值
id line | idsector |sector | isSectorPrior |etc...
1 | 1 | east | no
2 | 1 | east | no
3 | 1 | east | yes
4 | 1 | east | yes
5 | 2 | west | yes
6 | 2 | west | yes
7 | 2 | west | no
8 | 2 | west | yes
我要畫一條線在那裏isSectorPrior
將是「是」,並然後,當我有行,得到id line
即在小區1
所以在這裏,它可以選擇行3,4,5,6或8
我發現了很多或樣品,它使用範圍(an example),但它們可以返回例如第7行,儘管它有一個「否」。這不應該發生。
如何指定,隨機獲得一個排,但只有在iSectorPrio是肯定的?
我當前的代碼,沒有這麼多,因爲我沒有找到任何可以匹配的內容我想:
'get a sheet to use and find a random row
Set tempSheet = ActiveWorkbook.Sheets(1).Select
'loop 50 times, to draw 50 different lines
For i = 1 To 50
'todo : get randow row, where IsSelectPrio is yes
'then do whatever I want with it, like write copy it in another sheet or a csv
Next i
這裏(對我來說)的難度,沒有特別的範圍內,所有我發現正在使用該範圍。並且考慮到,在第一行中,它不是表格的一部分。
有沒有辦法做我想要的?
我認爲它可以使用返回多頭的數組,包含匹配的行ID的UDF下來。 UDF將採取您選擇的範圍。 – 2015-03-03 08:17:41