PDA

View Full Version : How select next blank cell in row and add timestap



sean.golds
12-08-2016, 07:56 AM
Guys/Gals,

I need to write some simple code so when a button is clicked, a time stamp is created in the next empty cell in a row on another worksheet within the same workbook. I realise this is a fairly simple request for someone well experienced but I'm really a beginner still.

Thanks,

Sean

JKwan
12-08-2016, 08:21 AM
try this

Private Sub CommandButton1_Click()
Dim LastRow As Long
Dim Output As Worksheet

Set Output = ThisWorkbook.Worksheets("Sheet2")
LastRow = FindLastRow(Output, "A") + 1
Output.Cells(LastRow, "A") = Now
End Sub
Function FindLastRow(ByVal WS As Worksheet, ColumnLetter As String) As Long
FindLastRow = WS.Range(ColumnLetter & Rows.Count).End(xlUp).Row
End Function

sean.golds
12-08-2016, 08:25 AM
Excellent JKwan! Works perfectly thanks...