Hi All, Thanks in advance for any help. I am trying to get a code to Subtract a value from a cell on another sheet using another cell name as the trigger. IE if sheet 1 cell A1 = 12345 the code must look up 12345 on sheet 2 and subtract sheet 1 cell 2 from sheet 2 say B8 (whichwere row it finds 12345).
I have tried to use this code which works unless I have the same trigger cell name - it wont subtract the figure twice? I Hope this makes sense.
I have tried to use this code which works unless I have the same trigger cell name - it wont subtract the figure twice? I Hope this makes sense.
Code:
Dim Rng3 As Range, Dn3 As Range
Dim Dic3 As Object
With Sheets("Report")
Set Rng3 = .Range(.Range("A6"), .Range("A" & Rows.Count).End(xlUp))
End With
Set Dic3 = CreateObject("scripting.dictionary")
Dic3.CompareMode = vbTextCompare
For Each Dn3 In Rng3
Dic3(Dn3.Value) = Dn3.Offset(, 7) 'OPERATOR/booked out QTY'
Next
With Sheets("Planning ")
Set Rng3 = .Range(.Range("A7"), .Range("A" & Rows.Count).End(xlUp))
End With
For Each Dn3 In Rng3
If Dic3.exists(Dn3.Value) Then
If Dn3.Offset(, 2) <> "Order quantity" Then
If Dn3.Offset(, 2) <> "Production cell" Then
If Dn3.Offset(, 3) <> "Outstanding order quantity" Then
If Dn3.Offset(, 3) <> "" Then
Dn3.Offset(, 3) = Dn3.Offset(, 3) - Dic3.Item(Dn3.Value)
End If
End If
End If
End If
End If
Next