Hi Expert,
May I ask your help on how to get the last row with data and get the cell value of column A. This is my other option to automate generating ticket number.
Please take a look also my existing codes if this is correct. thanks.
Here is my initial code.
Dim wb As Workbook Dim ws As Worksheet
Dim lRow As Long, lCol As Long
Dim rng As Range
Dim TextNum As String
Dim yfmt As String, fmt As String, datefmt As String, TicketNum As Variant, sample As String
yfmt = Format(Date, "yy")
mfmt = Format(Date, "mm")
datefmt = yfmt & mfmt
'~~> Set this to the relevant worksheet
Set wb = ThisWorkbook
Set ws = wb.Sheets("TransactionDB")
With ws
'~~> Get the last row
lRow = .Range("A" & .Rows.Count).End(xlUp).row
'~~> get the first column
lCol = .Cells(1, 1).End(xlToLeft).Column1
'~~> Set the range
Set rng = .Range(.Cells(lRow, 1), .Cells(lRow, lCol))
If Not rng Is Nothing Then
With rng
Debug.Print .Address
'?? how to get the cell value of last row 1st column
End With
Else
Me.TextBox1.Value = "L1" & datefmt & "-"
End If
End With