title: VBA - For ... Next Loop
body: <p>I'm trying to copy values ​​from one sheet to another, if the conditions are right. I did it with 3 nested loops. Unfortunately the code only gives me the first value.</p>
  <p>for example:</p>
  <p>i = 7, j = 3, k = 2</p>
  <p>(i, j) = (7,3) is an &quot;E&quot; in the &quot;Januar&quot; sheet. This E is then continuously copied and pasted.</p>
  <p>But I want the second value (i, j) = (7,4), which is an &quot;U&quot; copied and pasted and so on...</p>
  <p>I don't quite understand where the problem is in my code. I would be glad if someone can help me. I would also be happy about a better and faster solution.</p>
  <pre><code>Dim i As Integer, Dim j As Integer, Dim k As Integer
  
  For i = 7 To 37
      If Worksheets(&quot;Januar&quot;).Cells(i, 2).Value = Worksheets(&quot;Drucken&quot;).Cells(12, 12).Value Then
          For j = 3 To 5
              Worksheets(&quot;Januar&quot;).Cells(i, j).Copy
                  For k = 2 To 4
                      Worksheets(&quot;Drucken&quot;).Activate
                      Worksheets(&quot;Drucken&quot;).Cells(38, k).Select
                      ActiveSheet.Paste
                  Next
              Worksheets(&quot;Januar&quot;).Activate
          Next
      End If
  Next
  </code></pre>
  <p><strong>EDIT:</strong></p>
  <p>Here is what I want</p>
  <p>I want these values from Sheet(&quot;Januar&quot;) copied and pasted into
  <a href="https://i.stack.imgur.com/qHTpA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qHTpA.png" alt="enter image description here" /></a></p>
  <p>this Sheet(&quot;Drucken&quot;)
  <a href="https://i.stack.imgur.com/wKZgq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wKZgq.png" alt="enter image description here" /></a></p>
  <p>I solved the problem like this:</p>
  <pre><code>Dim i As Integer
     
  For i = 7 To 37
  If Worksheets(&quot;Januar&quot;).Cells(i, 2).Value = Worksheets(&quot;Drucken&quot;).Cells(12, 12).Value Then
          Worksheets(&quot;Januar&quot;).Cells(i, 3).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 2)
          Worksheets(&quot;Januar&quot;).Cells(i, 4).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 3)
          Worksheets(&quot;Januar&quot;).Cells(i, 5).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 4)
          Worksheets(&quot;Januar&quot;).Cells(i, 6).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 5)
          Worksheets(&quot;Januar&quot;).Cells(i, 7).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 6)
          Worksheets(&quot;Januar&quot;).Cells(i, 8).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 7)
          Worksheets(&quot;Januar&quot;).Cells(i, 9).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 8)
          Worksheets(&quot;Januar&quot;).Cells(i, 10).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 9)
          Worksheets(&quot;Januar&quot;).Cells(i, 11).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 10)
          Worksheets(&quot;Januar&quot;).Cells(i, 12).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 11)
          Worksheets(&quot;Januar&quot;).Cells(i, 13).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 12)
          Worksheets(&quot;Januar&quot;).Cells(i, 14).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 13)
          Worksheets(&quot;Januar&quot;).Cells(i, 15).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 14)
          Worksheets(&quot;Januar&quot;).Cells(i, 16).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 15)
          Worksheets(&quot;Januar&quot;).Cells(i, 17).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 16)
          Worksheets(&quot;Januar&quot;).Cells(i, 18).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 17)
          Worksheets(&quot;Januar&quot;).Cells(i, 19).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 18)
          Worksheets(&quot;Januar&quot;).Cells(i, 20).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 19)
          Worksheets(&quot;Januar&quot;).Cells(i, 21).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 20)
          Worksheets(&quot;Januar&quot;).Cells(i, 22).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 21)
          Worksheets(&quot;Januar&quot;).Cells(i, 23).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 22)
          Worksheets(&quot;Januar&quot;).Cells(i, 24).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 23)
          Worksheets(&quot;Januar&quot;).Cells(i, 25).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 24)
          Worksheets(&quot;Januar&quot;).Cells(i, 26).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 25)
          Worksheets(&quot;Januar&quot;).Cells(i, 27).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 26)
          Worksheets(&quot;Januar&quot;).Cells(i, 28).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 27)
          Worksheets(&quot;Januar&quot;).Cells(i, 29).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 28)
          Worksheets(&quot;Januar&quot;).Cells(i, 30).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 29)
          Worksheets(&quot;Januar&quot;).Cells(i, 31).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 30)
          Worksheets(&quot;Januar&quot;).Cells(i, 32).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 31)
          Worksheets(&quot;Januar&quot;).Cells(i, 33).Copy Worksheets(&quot;Drucken&quot;).Cells(38, 32)
  End If
  Next
  </code></pre>
  <p>But I think with for next loops its way better. But I dont know why its not working with the code above...</p>