I want to create a command button in excel such that every time I press the command button it does the following:
In Column A it increments the value of consecutive cells by 50 and at the same time in column B it time stamps.
Column A Column B
50 9:08:53pm
100 9:09:12pm
150 9:09:34pm
200 9:09:54pm
Does that make sense?
I am a non computer person, I have zero clue on VBA. Still I tried, I got the following program that just increments by 1 (it doesn't work for me, Runtime error 424, object required, have no clue what that is):
If Target.Columns.Count > 1 Or Target.Rows.Count > 1 Then Exit Sub
If Target.Address = "$B$1" Then
Target.Value = 1
Exit Sub
End If
If Target.Column <> 1 Then Exit Sub
If Target.Offset(-1) = vbNullString Then Exit Sub
If Target.Row > 1 And Target.Row < 51 Then
ActiveCell.Value = ActiveCell.Offset(-1).Value + 1
End If
I thought if I changed the Target .Value = 50 and Value + 1 to Value + 50 and it will work, then I can just link the following formula to time stamp it:
=IF(B1<>"",IF(A1="",NOW(),A1),"")
Also, the following is the program that my friend wrote but I don't know how to execute it, and it gives me run time error 13(again, no clue):
Sub Increment()
Dim i As Integer
Range("a1").Value = "Time"
Range("b1").Value = "Initial Count"
Range("c1").Value = "Incremented Count"
Range("b2").Value = 0
'Cells(2, 3).Value = Cells(2, 2).Value + 50
'j = i - 1
i = 1
'For i = 2 To 100
Cells(i + 1, 3).Value = Cells(2, 2).Value + Cells(i, 3).Value + 50
i = i + 1
'Next i
End Sub
PLEASE HELP
In Column A it increments the value of consecutive cells by 50 and at the same time in column B it time stamps.
Column A Column B
50 9:08:53pm
100 9:09:12pm
150 9:09:34pm
200 9:09:54pm
Does that make sense?
I am a non computer person, I have zero clue on VBA. Still I tried, I got the following program that just increments by 1 (it doesn't work for me, Runtime error 424, object required, have no clue what that is):
If Target.Columns.Count > 1 Or Target.Rows.Count > 1 Then Exit Sub
If Target.Address = "$B$1" Then
Target.Value = 1
Exit Sub
End If
If Target.Column <> 1 Then Exit Sub
If Target.Offset(-1) = vbNullString Then Exit Sub
If Target.Row > 1 And Target.Row < 51 Then
ActiveCell.Value = ActiveCell.Offset(-1).Value + 1
End If
I thought if I changed the Target .Value = 50 and Value + 1 to Value + 50 and it will work, then I can just link the following formula to time stamp it:
=IF(B1<>"",IF(A1="",NOW(),A1),"")
Also, the following is the program that my friend wrote but I don't know how to execute it, and it gives me run time error 13(again, no clue):
Sub Increment()
Dim i As Integer
Range("a1").Value = "Time"
Range("b1").Value = "Initial Count"
Range("c1").Value = "Incremented Count"
Range("b2").Value = 0
'Cells(2, 3).Value = Cells(2, 2).Value + 50
'j = i - 1
i = 1
'For i = 2 To 100
Cells(i + 1, 3).Value = Cells(2, 2).Value + Cells(i, 3).Value + 50
i = i + 1
'Next i
End Sub
PLEASE HELP