title: Excel VBA: How to use changing cell values in For Each statement?
body: <p>So I've build the following Macro that almost captures whats it needs to do. It copies data form one sheet3, pastes the data in sheet1. After which it replaces variables1-7 with values that are to be found in sheet2.</p>
  
  <p>The Macro works just fine when it is Executed for one row. However I would like it to loop through all the filled in rows in Sheet2 and replace the variables with the corresponding row values in Sheet2.</p>
  
  <p>Hoping to find the answer here, since I'm quite new to VBA and haven't been able to find the answer yet.</p>
  
  <pre><code>Sub Macro1()
  
  For Each c In Sheets("Sheet2").Range("A2:G13").Rows
  
  Sheets("Sheet3").Activate
  Range("A1:AH125").Select
  Application.CutCopyMode = False
  Selection.Copy
  Sheets("Sheet1").Activate
  lMaxRows = Cells(Rows.Count, "A").End(xlUp).row
  Range("A" &amp; lMaxRows + 1).Select
  ActiveSheet.Paste
  
  Selection.Replace What:="Variable1", Replacement:=Sheets("Sheet2").Range("A").Value, LookAt:=xlPart, _
      SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
      ReplaceFormat:=False
  Selection.Replace What:="Variable2", Replacement:=Sheets("Sheet2").Range("B").Value, LookAt:=xlPart, _
      SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
      ReplaceFormat:=False
  Selection.Replace What:="Variable3", Replacement:=Sheets("Sheet2").Range("C").Value, LookAt:=xlPart, _
      SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
      ReplaceFormat:=False
  Selection.Replace What:="Variable4", Replacement:=Sheets("Sheet2").Range("D").Value, LookAt:=xlPart, _
      SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
      ReplaceFormat:=False
  Selection.Replace What:="Variable5", Replacement:=Sheets("Sheet2").Range("E").Value, LookAt:= _
      xlPart, SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
      ReplaceFormat:=False
  Selection.Replace What:="Variable6", Replacement:=Sheets("Sheet2").Range("F").Value, LookAt:=xlPart, _
      SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
      ReplaceFormat:=False
  Selection.Replace What:="Variable7", Replacement:=Sheets("Sheet2").Range("G").Value, LookAt:=xlPart, _
      SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
      ReplaceFormat:=False
  
  Next
  
  End Sub
  </code></pre>