How to apply the same code to all rows in VBA, Excel
Simple question, I'm new to VBA - how do I apply the following code to all rows (except the first two) without manually writing it for every single one?
Thanks!!
Code:
Sub DueUpdate()
'
' DueUpdate Macro
'
'
If Range("I3").Value <> Completed Then Range("F3").Copy Range("G3")
If Range("I4").Value <> Completed Then Range("F4").Copy Range("G4")
If Range("I5").Value <> Completed Then Range("F5").Copy Range("G5")
If Range("I6").Value <> Completed Then Range("F6").Copy Range("G6")
If Range("I7").Value <> Completed Then Range("F7").Copy Range("G7")
If Range("I8").Value <> Completed Then Range("F8").Copy Range("G8")
If Range("I9").Value <> Completed Then Range("F9").Copy Range("G9")
If Not Range("A1").Value <> Tracker Then
End If
End Sub
Re: How to apply the same code to all rows in VBA, Excel
Code:
Sub DueUpdate()
Dim i As Long
For i=3 To 9
If Range("I" & i).Value<> Completed Then Range("F" & i).Copy Range ("G" & i)
Next
End Sub
I do hope that "Completed" is a Function.....
Re: How to apply the same code to all rows in VBA, Excel
No completed is not a function, it is a condition. It's looking if the cell contains the word completed.
Re: How to apply the same code to all rows in VBA, Excel
Then you have to put in Parantheses
If Range.Value<>"Completed" Then...