MistakesWereMade
Board Regular
- Joined
- May 22, 2019
- Messages
- 103
I have a 'for loop' that is supposed to compare a cell in the master workbook with a set value, and then delete a row in the new workbook based on whether the condition is met or not. Currently, my loop runs and every row in the new workbook is deleted...
m is equal to 3 and the initial condition of Cell(n, 15).Value is 2.
If I set the if loops to "... <> m -1", the loop works fine for some reason and deletes every row that doesn't contain 2 in the new workbook. BUT, I need it to work with "...<> m" because m is a changing vector.
m is equal to 3 and the initial condition of Cell(n, 15).Value is 2.
If I set the if loops to "... <> m -1", the loop works fine for some reason and deletes every row that doesn't contain 2 in the new workbook. BUT, I need it to work with "...<> m" because m is a changing vector.
VBA Code:
For n = ThisWb.Sheets(1).Cells(Rows.Count, 12).End(xlUp).Row To 2 Step -1
If ThisWb.Sheets(1).Cells(n, 15).Value <> m Then
wbTemp.Sheets(1).Rows(n).Delete
End If
Next n