title: Determine Value of a Cell by two variables
body: <p><strong>My Issue:</strong></p>
  
  <p>I want to loop through a range, and whenever it finds a duplicate value, it should take the amount from the cell with offset to the right of it, and add that to the value of the first Cells amount. I have a macro, which can determine if it finds a duplicate, but if it has several duplicates, then I want it to redo the task, but just continue to find the duplicates and add up the amount :)</p>
  
  <p><strong>What I have so far:</strong></p>
  
  <pre><code>    Sub LoopThroughRangeAndFindDuplicates ()
  
      NumberOne = sht.Range("1:1").Find("Bilagsnr.").Address(False, False, xlA1)
      Number = Application.WorksheetFunction.Substitute(FindNo, 1, "")
      rng1 = NumberOne &amp; ":" &amp; Number &amp; LastRow
  
      No1Off = sht.Range(NumberOne).Offset(1, 0).Address(False, False, xlA1)
  
  For Each c In sht.Range(rng1).Cells
      rngOff1 = No1Off &amp; ":" &amp; Number &amp; LastRow + 1
          With Wf
          n = .CountIfs(Range(rngOff1), c)
              If n &gt; 0 Then
                  CDuplicate = sht.Range(rngOff1).Find(c).Address(False, False, xlA1)
                  CDuplicateSub = Application.WorksheetFunction.Substitute(CDuplicate, Number, Amount)
                  CDuplicateSubValue = sht.Range(CDuplicateSub).Value
                  CValue = c.Address(False, False, xlA1)
                  CValueSub = Application.WorksheetFunction.Substitute(CValue, Number, Amount)
                  CValueSubValue = sht.Range(CValueSub).Value
                  sht.Range(CValueSub).Value = CValueSubValue + CDuplicateSubValue
              End If
      End With
      No1Off = sht.Range(No1Off).Offset(1, 0).Address(False, False, xlA1)
  Next c
  </code></pre>
  
  <p><strong>Goal:</strong></p>
  
  <p>As requested in the above, I want the macro to redo the <code>If n &gt; 0 Then</code> if it has more duplicates than x. How should I write my code, to get it to look for several duplicates, and add them up, before continuing, without making a <code>For Each</code> string that will be really long? :)</p>