• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to indicate 'starting value'

Marcych

New Member
Hello Guys,

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
 

Attachments

  • BHD TOOL - Copy.xlsm
    58.8 KB · Views: 2
Marcych
If You set r = Range("A" & LR) then how many cel would Your For Each cel In r do?
If You set r = Range("A1:A" & LF) then there would be much more cel to do.
 
Back
Top