2017-07-31 3 views
0

私のコードは、私は、列1から80アクセス列

Dim arrEntireWs2() as Variant 
With ws2 
    arrEntireWs2 = .Range(.Cells(2,1),.Cells(lastRow22,80)).Value 
End With 
に配列に列全体を入れ、以下を有するシートを割り当て、行カウントを

Set ws2 = ThisWorkbook.Worksheets("Sheet2") 
lastRow22 As Long 
lastRow22 = ws2.Cells(ws2.Rows.Count, "A").End(xlUp).Row 

をつかんで始まります

それから私のループはそれ

Dim lngArrEntireWs2Index as Long 
For lngArrEntireWs2Index = LBound(arrEntireWs2,1) to Ubound(arrEntireWs2,1) 
    'Things I want to do 
Next lngArrEntireWs2Index 

を通じて私の質問は、私が上の特定の列で値を取得行う方法ですそれはループしている行ですか?どのように私はループを通過する間に列10にあるものをつかむだろうか?

答えて

1

これは、youreの探しものです....

Dim lngArrEntireWs2Index as Long 
For lngArrEntireWs2Index = LBound(arrEntireWs2,1) to Ubound(arrEntireWs2,1) 
    If arrEntireWs2(lngArrEntireWs2Index, 10) Then 
      debug.print; arrEntireWs2(lngArrEntireWs2Index, 10) 
    End if 
Next lngArrEntireWs2Index 

これは

Dim ws2 as workbook 
Set ws2 = ThisWorkbook.Worksheets("Sheet2") 

Dim arr2 as Variant 
With ws2 
    arr2 = .UsedRange 
End With 

Dim i as Long 
For i= LBound(arr2,1) to Ubound(arr2,1) 
    If arr2(i, 11) Then 
     debug.print; arr2(i, 11) 
    End if 
Next i 
+0

私に良く見えるFYI命名規則はちょっと不格好であり、困難readibilityのために作ります –