Nlhicks
Board Regular
- Joined
- Jan 8, 2021
- Messages
- 244
- Office Version
- 365
- Platform
- Windows
This code works perfectly with only one input but if the user want to enter 3 different lines then I need it to capture all three lookups in different lines.
Sub DoMath()
Dim Ws As Worksheet
Dim i As Long
Set Ws = Sheets("Line Update")
For x = 1 To InputBox
For i = 0 To 1
If Ws.Cells(11, "C").Value <> Ws.Cells(11, "F").Value Then
Ws.Cells(13, "L").Value = Ws.Cells(11, "F") - Ws.Cells(11, "C")
End If
If Ws.Cells(13 + i, "C").Value <> Ws.Cells(13 + i, "F").Value Then
Ws.Cells(13, "M").Value = Ws.Cells(13, "F") - Ws.Cells(13, "C")
End If
If Ws.Cells(15 + i, "C").Value <> Ws.Cells(15 + i, "F").Value Then
Ws.Cells(13, "O").Value = Ws.Cells(15, "F") - Ws.Cells(15, "C")
End If
If Ws.Cells(17 + i, "C").Value <> Ws.Cells(17 + i, "F").Value Then
Ws.Cells(13, "P").Value = Ws.Cells(17, "F") - Ws.Cells(17, "C")
End If
Next i
Next x
End Sub
Sub DoMath()
Dim Ws As Worksheet
Dim i As Long
Set Ws = Sheets("Line Update")
For x = 1 To InputBox
For i = 0 To 1
If Ws.Cells(11, "C").Value <> Ws.Cells(11, "F").Value Then
Ws.Cells(13, "L").Value = Ws.Cells(11, "F") - Ws.Cells(11, "C")
End If
If Ws.Cells(13 + i, "C").Value <> Ws.Cells(13 + i, "F").Value Then
Ws.Cells(13, "M").Value = Ws.Cells(13, "F") - Ws.Cells(13, "C")
End If
If Ws.Cells(15 + i, "C").Value <> Ws.Cells(15 + i, "F").Value Then
Ws.Cells(13, "O").Value = Ws.Cells(15, "F") - Ws.Cells(15, "C")
End If
If Ws.Cells(17 + i, "C").Value <> Ws.Cells(17 + i, "F").Value Then
Ws.Cells(13, "P").Value = Ws.Cells(17, "F") - Ws.Cells(17, "C")
End If
Next i
Next x
End Sub