October 5, 2010
Hi Mariya,
Please see attached. Splitting up the code is pretty straightforward using VBA string functions
You could also read my Excel Forms posts to help you learn a bit more
Please note: the code in the workbook will only work if the code is always the same structure, that is, the same length and each of the substrings are the same length and in the same position.
Regards
Phil
Answers Post
Trusted Members
Moderators
November 1, 2018
FWIW, you could also use a couple of user-defined types, like this:
Private Type theBarcode
theCode As String * 30
End Type
Private Type BarcodeParts
BatchNumber As String * 7
space1 As String * 1
CodeNumber As String * 8
space2 As String * 1
Section As String * 1
space3 As String * 1
RequiredDate As String * 5
Prefix As String * 6
End Type
Private Sub CommandButton1_Click()
Dim BarCode As theBarcode
Dim theParts As BarcodeParts
BarCode.theCode = Range("B9").Value
LSet theParts = BarCode
tbScan.Value = BarCode.theCode
With theParts
BatchNum.Value = .BatchNumber
BatchMonth.Value = Left(.BatchNumber, 4)
Code.Value = .CodeNumber
Section.Value = .Section
RequiredDate.Value = .RequiredDate
Prefix.Value = .Prefix
End With
End Sub
1 Guest(s)