title: Excel VBA Macro - Set Row Variables On Separate Sheets Equal to Each Other
body: <p>I've found questions and answers very similar to my question, but nothing that addresses the specific question I have.  With my macro I want to say: </p>
  
  <p>If Column "M", Row 6 on the Analysis Worksheet is not empty AND Column "B" Row 6 AND Column "C" Row 6 AND Column "D" Row 6 (all on Analysis Worksheet) are empty AND Column "C" Row 6 on Fixed Cost Test Data Worksheet is not empty AND the value of Column "C" Row 6 on Fixed Cost Test Data is >= Today's Date, THEN I want the value of Column "M", Row 6 on the Analysis Worksheet to be calculated as: </p>
  
  <p><code>Sheets("Analysis Worksheet").Range("M" &amp; i).Value = (Sheets("Analysis Worksheet").Range("M" &amp; i).Value - Sheets("Fixed Cost Test Data").Range("B" &amp; j).Value) - ((Sheets("Analysis Worksheet").Range("M" &amp; i).Value - Sheets("Fixed Cost Test Data").Range("B" &amp; j).Value) * (Sheets("Analysis Worksheet").Range("E" &amp; i).Value * 0.01))</code></p>
  
  <p>I want i = j.  i and j are the same number/same row. </p>
  
  <p>What do I need to change in my code so when it performs calculations for a row on Analysis Worksheet, it is using the same row's values on Fixed Cost Test Data Worksheet and the rows stay 'in sync' as they move down the worksheet together? </p>
  
  <p>This is the code I have for the macro:</p>
  
  <pre><code>Sub ReduceCost_Percentage()
  
      With Worksheets("Analysis Worksheet")
  
          Dim i As Long
          Dim LastRow As Long
          LastRow = Range("X" &amp; Rows.Count).End(xlUp).Row
  
          Dim j As Long
          j = i
          Dim LRow As Long
          LRow = Worksheets("Fixed Cost Test Data").Range("C" &amp; Rows.Count).End(xlUp).Row
  
          For i = 5 To LastRow
              For j = i To i
  
                  If Sheets("Analysis Worksheet").Range("E" &amp; i).Value &gt; 0 And IsEmpty(Sheets("Analysis Worksheet").Range("B" &amp; i).Value) _
                     And IsEmpty(Sheets("Analysis Worksheet").Range("C" &amp; i).Value) And IsEmpty(Sheets("Analysis Worksheet").Range("D" &amp; i).Value) _
                     And Not IsEmpty(Sheets("Analysis Worksheet").Range("M" &amp; i).Value) And Not IsEmpty(Worksheets("Fixed Cost Test Data").Range("C" &amp; j).Value) And (Date &gt;= Worksheets("Fixed Cost Test Data").Range("C" &amp; j).Value) Then
  
                      Sheets("Analysis Worksheet").Range("M" &amp; i).Value = (Sheets("Analysis Worksheet").Range("M" &amp; i).Value - Sheets("Fixed Cost Test Data").Range("B" &amp; j).Value) - ((Sheets("Analysis Worksheet").Range("M" &amp; i).Value - Sheets("Fixed Cost Test Data").Range("B" &amp; j).Value) * (Sheets("Analysis Worksheet").Range("E" &amp; i).Value * 0.01))
  
                  ElseIf Sheets("Analysis Worksheet").Range("E" &amp; i).Value &gt; 0 And IsEmpty(Sheets("Analysis Worksheet").Range("B" &amp; i).Value) _
                         And IsEmpty(Sheets("Analysis Worksheet").Range("C" &amp; i).Value) And IsEmpty(Sheets("Analysis Worksheet").Range("D" &amp; i).Value) _
                         And Not IsEmpty(Sheets("Analysis Worksheet").Range("M" &amp; i).Value) And (IsEmpty(Worksheets("Fixed Cost Test Data").Range("C" &amp; j).Value) Or Worksheets("Fixed Cost Test Data").Range("C" &amp; j).Value &gt; Date) Then
  
                      Sheets("Analysis Worksheet").Range("M" &amp; i).Value = Sheets("Analysis Worksheet").Range("M" &amp; i).Value - (Sheets("Analysis Worksheet").Range("M" &amp; i).Value * (Sheets("Analysis Worksheet").Range("E" &amp; i).Value * 0.01))
  
                  End If
  
              Next j
          Next i
  
          For i = 5 To LastRow
              For j = i To i
  
                  If Sheets("Analysis Worksheet").Range("E" &amp; i).Value &gt; 0 And IsEmpty(Sheets("Analysis Worksheet").Range("B" &amp; i).Value) _
                     And IsEmpty(Sheets("Analysis Worksheet").Range("C" &amp; i).Value) And IsEmpty(Sheets("Analysis Worksheet").Range("D" &amp; i).Value) _
                     And Not IsEmpty(Sheets("Analysis Worksheet").Range("N" &amp; i).Value) And Not IsEmpty(Sheets("Fixed Cost Test Data").Range("C" &amp; j).Value) And (Date &gt;= Sheets("Fixed Cost Test Data").Range("C" &amp; j).Value) Then
  
                      Sheets("Analysis Worksheet").Range("N" &amp; i).Value = (Sheets("Analysis Worksheet").Range("N" &amp; i).Value - Sheets("Fixed Cost Test Data").Range("B" &amp; j).Value) - ((Sheets("Analysis Worksheet").Range("N" &amp; i).Value - Sheets("Fixed Cost Test Data").Range("B" &amp; j).Value) * (Sheets("Analysis Worksheet").Range("E" &amp; i).Value * 0.01))
  
                  ElseIf Sheets("Analysis Worksheet").Range("E" &amp; i).Value &gt; 0 And IsEmpty(Sheets("Analysis Worksheet").Range("B" &amp; i).Value) _
                         And IsEmpty(Sheets("Analysis Worksheet").Range("C" &amp; i).Value) And IsEmpty(Sheets("Analysis Worksheet").Range("D" &amp; i).Value) _
                         And Not IsEmpty(Sheets("Analysis Worksheet").Range("N" &amp; i).Value) And (IsEmpty(Sheets("Fixed Cost Test Data").Range("C" &amp; j).Value) Or Sheets("Fixed Cost Test Data").Range("C" &amp; j).Value &gt; Date) Then
  
                      Sheets("Analysis Worksheet").Range("N" &amp; i).Value = Sheets("Analysis Worksheet").Range("N" &amp; i).Value - (Sheets("Analysis Worksheet").Range("N" &amp; i).Value * (Sheets("Analysis Worksheet").Range("E" &amp; i).Value * 0.01))
  
                  End If
  
              Next j
          Next i
  
          '....Continues until Cell "X"
  
      End With
  End Sub
  </code></pre>