Increase

  • Thread starter Thread starter Workbook
  • Start date Start date
W

Workbook

Is there a code that will scan every even cell in column F for a quantity and
if it finds a quantity it will add a “1†to the quantity?
 
Dim lR As Long
With Sheets("Sheet1")
For lR = 1 To .Cells(.Rows.Count, "F").End(xlUp).Row
If WorksheetFunction.IsNumber(.Cells(lR, "F")) And _
Not .Cells(lR, "F").HasFormula Then
.Cells(lR, "F") = .Cells(lR, "F") + 1
End If
Next
End With
 
The OP wanted to add one to only the even rows (he said "even cells", but
that is what I think he meant), so the loop counter should start at 2 and
Step 2 needs to be added to the end of your For statement...

Dim lR As Long
With Sheets("Sheet1")
For lR = 2 To .Cells(.Rows.Count, "F").End(xlUp).Row Step 2
If WorksheetFunction.IsNumber(.Cells(lR, "F")) And _
Not .Cells(lR, "F").HasFormula Then
.Cells(lR, "F") = .Cells(lR, "F") + 1
End If
Next
End With
 
Back
Top