Home > Software design >  Calculate Time of each row excel
Calculate Time of each row excel

Time:04-16

I want to calculate the times of each Row in Column J and I i.e. =J2-I2 I got some help earlier and wrote up this VBA code

Private Sub CommandButton1_Click()
For i = 2 To 1647 / Range("J" & i) - Range("I" & i)
Next i
End Sub

and I want it to post the calculation in each row of column K starting with row two the calculation. But I am getting the method range of object _worksheet failed error everytime I click the button to run the command. How can I get this error to stop and make this work?

CodePudding user response:

Private Sub CommandButton1_Click()
For i = 2 To 1647 Step 1
    Range("K" & i).Value = Range("J" & i).Value - Range("I" & i).Value
Next i
End Sub

For...Next statement

  • Related