Try to remove the Exit Sub
line.
I would like for my command to repeat through each row, at the moment it only runs on 1 row
Roberto
20
Reputation points
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
Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
5,770 questions
Bing Spell Check
Bing Spell Check
A Bing service that detects and corrects spelling mistakes in your app.
38 questions
Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
12,075 questions
Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
2,176 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
43,643 questions
Accepted answer
-
Viorel 121.8K Reputation points
2023-10-02T14:30:59.21+00:00