Generating alphanumeric code
Closed
Pankaj2411
Posts
1
Registration date
Wednesday July 8, 2015
Status
Member
Last seen
July 9, 2015
-
Jul 9, 2015 at 05:54 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Jul 13, 2015 at 12:15 PM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Jul 13, 2015 at 12:15 PM
Related:
- Generating alphanumeric code
- Battery reset code - Guide
- Samsung volume increase code - Guide
- How to get whatsapp verification code online - Guide
- Cs 1.6 code - Guide
- Samsung keypad reset code - Guide
2 responses
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Jul 9, 2015 at 11:18 AM
Jul 9, 2015 at 11:18 AM
Hi Pankaj,
Could let us know how you want this to work?
Like what determines if the string should start with L, P, G or T? Where should this string be placed?
Best regards,
Trowa
Could let us know how you want this to work?
Like what determines if the string should start with L, P, G or T? Where should this string be placed?
Best regards,
Trowa
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Jul 13, 2015 at 12:15 PM
Jul 13, 2015 at 12:15 PM
Hi Pankaj,
Not entirely clear, so let's start with the following:
First I made my sheet look like this:
Then running the code below and entering either C, O, T or L when asked for will generate the "code" as requested.
Try it and let me know your thoughts.
Best regards,
Trowa
Monday, Tuesday and Thursday are usually the days I'll respond. Bear this in mind when awaiting a reply.
Not entirely clear, so let's start with the following:
First I made my sheet look like this:
Then running the code below and entering either C, O, T or L when asked for will generate the "code" as requested.
Sub RunMe() Dim pType As String Dim mNumber, cLength As Integer pType = InputBox("Please enter Payment Type letter:") If pType = "C" Then mNumber = Mid(Range("A" & Rows.Count).End(xlUp), 2, 4) + 1 cLength = Len(mNumber) Do Until cLength = 4 cLength = cLength + 1 mNumber = "0" & mNumber Loop Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = "C" & mNumber & Format(Now, "MMYY") ElseIf pType = "O" Then mNumber = Mid(Range("B" & Rows.Count).End(xlUp), 2, 4) + 1 cLength = Len(mNumber) Do Until cLength = 4 cLength = cLength + 1 mNumber = "0" & mNumber Loop Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Value = "C" & mNumber & Format(Now, "MMYY") ElseIf pType = "T" Then mNumber = Mid(Range("C" & Rows.Count).End(xlUp), 2, 4) + 1 cLength = Len(mNumber) Do Until cLength = 4 cLength = cLength + 1 mNumber = "0" & mNumber Loop Range("C" & Rows.Count).End(xlUp).Offset(1, 0).Value = "C" & mNumber & Format(Now, "MMYY") ElseIf pType = "L" Then mNumber = Mid(Range("D" & Rows.Count).End(xlUp), 2, 4) + 1 cLength = Len(mNumber) Do Until cLength = 4 cLength = cLength + 1 mNumber = "0" & mNumber Loop Range("D" & Rows.Count).End(xlUp).Offset(1, 0).Value = "C" & mNumber & Format(Now, "MMYY") End If End Sub
Try it and let me know your thoughts.
Best regards,
Trowa
Monday, Tuesday and Thursday are usually the days I'll respond. Bear this in mind when awaiting a reply.
Jul 13, 2015 at 08:00 AM
Rgds,