2017-04-10 10 views
-1

わかりました。これを実行するために何かを考え出しています。リストからの値に基づくVBAループ機能

基本的には、シート2で列Aの値をループする必要があります。各値に対して、シート1でそれを見つける必要があります。列Hの識別子(4変数)に基づいて、 1つの基準を満たしている場合、どの値を知るために列Kをチェックする必要があるかもしれない。例えば

:番号「123456789」を有するシートを2行2における

スタート、列Bに番号「123456789」を有するシートで1件の検索行(従って、B *の見出さ) H場合* 1つの値がある場合は、シート番号2の正しい列のロガーに値を追加する必要があります。 H * =ある基準の場合、列Kの基準をチェックしてから、正しい列に値を追加する必要があります。 私はちょうどこれを設定する方法と完全に失われています。 すべてのヘルプは素晴らしいだろう、次のように、多くの感謝

ジョン

コードは以下のようになります。ここでは サブStatus_Trackを()

Dim a As Long 'topic number 
Dim Z As Integer 
Dim R As Integer 
Dim i As Integer 
Dim S As Integer 
Dim D As Integer 

Worksheets("RAW").Activate 
R = Cells(Rows.Count, 2).End(xlUp).Row 
C = Cells(1, Columns.Count).End(xlToLeft).Column 

Z = 0 
i = 2 
Do Until i > R 

'ident 
If Cells(i, 2) = Worksheets("Data").Cells(i, 2) And (Cells(i, 13) = "ERKA")Then 
Z = Cells(i, 6) + 1 
Worksheets("RAW").Cells(i, 6).Value = Z 
Else 
If Cells(i, 2) = Worksheets("Data").Cells(i, 2) And (Cells(i, 13) = "INBA") Then 
'Inba 
Z = Cells(i, 7) + 1 
Worksheets("RAW").Cells(i, 7).Value = Z 
    Else 
    If Cells(i, 2) = Worksheets("Data").Cells(i, 2) And (Cells(i, 13) = "ABGE") Then 
    'Abge 
    Z = Cells(i, 8) + 1 
    Worksheets("RAW").Cells(i, 8).Value = Z 
    Else 
    If Cells(i, 2) = Worksheets("Data").Cells(i, 2) And (Cells(i, 13) = "GELO") Then 
    'Gelo 
    Z = Cells(i, 5) + 1 
    Worksheets("RAW").Cells(i, 5).Value = Z 
    Else 
    If Cells(i, 2) = Worksheets("Data").Cells(i, 2) And (Cells(i, 13) = "UEBE") And (Cells(i, 11) = 0) Then 
    'UEBE 
    Z = Cells(i, 10) + 1 
    Worksheets("Data").Cells(i, 9).Value = Z 
    Else 
    If Cells(i, 11) = 1 And (Cells(i, 28) = "<1") Then 
    '1 
    Z = Cells(i, 10) + 1 
    Worksheets("Data").Cells(i, 10).Value = Z 
    Else 
    If Cells(i, 11) = 1 And (Cells(i, 28) = "6") Then 
     '6 
     Z = Cells(i, 10) + 1 
     Worksheets("Data").Cells(i, 11).Value = Z 
     Else 
     If Cells(i, 11) = 1 And (Cells(i, 28) = "9") Then 
     '9 
     Z = Cells(i, 10) + 1 
     Worksheets("Data").Cells(i, 12).Value = Z 
     Else 
     If Cells(i, 11) = 1 And (Cells(i, 28) = "10") Then 
     '10 
     Z = Cells(i, 10) + 1 
     Worksheets("Data").Cells(i, 13).Value = Z 
     Else 
     If Cells(i, 11) = 1 And (Cells(i, 28) = "15") Then 
     '15 
     Z = Cells(i, 10) + 1 
     Worksheets("Data").Cells(i, 14).Value = Z 
      Else 
      If Cells(i, 11) = 1 And (Cells(i, 28) = "30") Then 
      '30 
      Z = Cells(i, 10) + 1 
      Worksheets("Data").Cells(i, 15).Value = Z 
      Else 
      If Cells(i, 11) = 1 And (Cells(i, 28) = "50") Then 
      '50 
      Z = Cells(i, 10) + 1 
      Worksheets("Data").Cells(i, 16).Value = Z 
      Else 
      If Cells(i, 11) = 1 And (Cells(i, 28) = "60") Then 
      '60 
      Z = Cells(i, 10) + 1 
      Worksheets("Data").Cells(i, 17).Value = Z 
      Else 
      If Cells(i, 11) = 1 And (Cells(i, 28) = "70") Then 
      '70 
      Z = Cells(i, 10) + 1 
      Worksheets("Data").Cells(i, 18).Value = Z 
       Else 
       If Cells(i, 11) = 1 And (Cells(i, 28) = "80") Then 
       '80 
       Z = Cells(i, 10) + 1 
       Worksheets("Data").Cells(i, 19).Value = Z 
       Else 
       If Cells(i, 11) = 1 And (Cells(i, 28) = "90") Then 
       '90 
       Z = Cells(i, 10) + 1 
       Worksheets("Data").Cells(i, 20).Value = Z 
       Else 
       If Cells(i, 11) = 1 And (Cells(i, 28) = "97") Then 
       '97 
       Z = Cells(i, 10) + 1 
       Worksheets("Data").Cells(i, 21).Value = Z 
       Else 
       If Cells(i, 11) = 1 And (Cells(i, 28) = "100") Then 
       '100 
       Z = Cells(i, 10) + 1 
       Worksheets("Data").Cells(i, 22).Value = Z 
       End If 
       End If 
       End If 
      End If 
      End If 
      End If 
      End If 
     End If 
     End If 
     End If 
     End If 
    End If 
    End If 
    End If 
    End If 
End If 
End If 

End Sub 

答えて

0

あなたはエクセルシートのセルを反復処理の例があります。

Sub test() 
    Dim range1 As Range 
    Dim cell As Range 

    Set range1 = ActiveWorkbook.Sheets("Your sheet name").Range("A1:A5") 

    For Each cell In range1 
     Debug.Print cell.Value 
    Next cell 
End Sub 

Debug.Printの代わりに、別のループを追加して、別のワークシートの値をチェックすることができます。

+0

ありがとう、 私はコードを書いたようですが、私はエラーmaeesagesを得続けます。 また、長すぎるのでここにアップロードできません。 –

+0

どのようなエラーが表示されますか? –

+0

エラーオーバーフロー。 上記のコードは私が持っている限りですが、うまくいかないようです。 –

関連する問題