Insert value into next available cell in range?

mrphilk

Board Regular
Joined
Jun 6, 2010
Messages
75
Hi,

I am making a sheet to run time trials and would like to add a time value in a cell at the click of a button, like so;

Sub Button2_Click()
Range("C4").Value = Time
End Sub

I will add a second value and subtract the difference (this is to record machine stoppages).

Is there a way of entering the value in the next available cell in a range, so for example the first click would be C1, then C2, then C3 etc etc.

Thanks
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
If you did this


Code:
Sub Button2_Click()
Dim LastRow
LastRow = Range("C65536").End(xlUp).Row
Range("C" & LastRow).Value = Time
End Sub
 
Last edited:
Upvote 0
Try

Code:
Sub Button2_Click()
Range("C" & Rows.Count).End(xlUp).Offset(1).Value = Time
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,896
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top