I would like for my command to repeat through each row, at the moment it only runs on 1 row

Roberto 20 Reputation points
2023-10-02T13:47:17.27+00:00
I have the  current VBA
Sub Subtract()
cPart = Sheet3.Range("a2, a1000")
cQty = Sheet3.Range("b2, b1000")
'loop

lastrow = Sheet1.Cells(Rows.Count, 1).End(xlUp).row
For i = 2 To lastrow
    If Sheet1.Cells(i, 1) = cPart Then
        'found it
        Sheet1.Cells(i, 4) = Sheet1.Cells(i, 4) - cQty
        Exit Sub

    End If

Next i

End Sub
This only runs for 1 row, but I would like for it to repeat through every active row.. Please help
Bing Bing Search APIs Bing Spell Check API
Microsoft 365 and Office Install, redeem, activate For business Windows
Microsoft 365 and Office Excel For business Windows
Windows for business Windows Client for IT Pros User experience Other
Community Center Not monitored
{count} votes

Accepted answer
  1. Viorel 122.5K Reputation points
    2023-10-02T14:30:59.21+00:00

    Try to remove the Exit Sub line.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.