Hello Guys,
Could you please advise how to indicate 'starting value' for LastRow? (if that's possible)?
Please see below:
The code is working well but I would like to start counting from specific value e.g. 10000 = [BHD#10000]. The case is that I don't want UserForm to write [BHD#10000] into cell A10000 but have this results starting from A1,A2,A3...
Regards,
Marcych
Could you please advise how to indicate 'starting value' for LastRow? (if that's possible)?
Please see below:
Code:
Private Sub btwNewTicket_Click()
ClearFields
Dim LR As Long
Dim r As Range, cel As Range
LR = Range("A" & Rows.Count).End(xlUp).Row
Set r = Range("A" & LR)
For Each cel In r
If r.Value = "" Then
r.Value = 1
Else
r.Offset(1).Value = r.Value + 1
r.Value = "[BHD#" & Format(r.Value, ["00000"]) & "]"
Me.tbTicketNo.Value = r.Value
Me.tbTicketNo.Locked = True
Me.tbDateOpen = Date
Me.btnAccept.Caption = "Create"
Me.btnAccept.Enabled = True
End If
Next cel
End Sub
The code is working well but I would like to start counting from specific value e.g. 10000 = [BHD#10000]. The case is that I don't want UserForm to write [BHD#10000] into cell A10000 but have this results starting from A1,A2,A3...
Regards,
Marcych