Hat sich gerade erledigt. So sieht nun der Code aus. Am ende kommt zwar immer noch die gleich Fehlermeldung, aber das Programm tut erstmal das was es soll:
Sub ErzeugeBarcode()
' Variablen Deklaration
Dim BarcodeBereich As String
Dim ArtNrSpalte As String
Dim Tabele
Dim CodierungZelle As String
Dim Y As Double
Dim x As Double
Dim Art1 As Integer
Dim Art2 As Integer
Dim Art3 As Integer
Dim Art4 As Integer
Dim Art5 As Integer
Dim Art6 As Integer
Dim Art7 As Integer
' Variablen Initialisierung
BarcodeBereich = Sheets("Operator").Cells(3, 6)
Tabele = Range("Operator!B1").Value
ArtNrSpalte = Range("Operator!B2").Value
CodierungZelle = Range("Operator!B4").Value
' Formatierung der Barcode Zellen
Sheets(Tabele).Activate
Columns("B:DC").ColumnWidth = 0.2
For Y = 0 To Cells(Rows.Count, 1).End(xlUp).Row
Debug.Print Y
'Vergabe der 7 Zahlenpaare des Barcodes
Art1 = Left(Sheets("Testfeld").Cells(2, 1).Offset(Y, 0).Value, 2)
Art2 = Left(Right(Sheets("Testfeld").Cells(2, 1).Offset(Y, 0).Value, 6), 2)
Art3 = Left(Right(Sheets("Testfeld").Cells(2, 1).Offset(Y, 0).Value, 4), 2)
Art4 = Left(Right(Sheets("Testfeld").Cells(2, 1).Offset(Y, 0).Value, 2), 2)
Art5 = 0
Art6 = 0
' Ermittlung der Prüfziffer
' Art7 = 10 - Right(Left(Range("Testfeld!A3").Value, 1) * 3 + Left(Right(Range("Testfeld!A3").Value, 7), 1) * 1 + Left(Right(Range("Testfeld!A3").Value, 6), 1) * 3 + Left(Right(Range("Testfeld!A3").Value, 5), 1) * 1 + Left(Right(Range("Testfeld!A3").Value, 4), 1) * 3 + Left(Right(Range("Testfeld!A3").Value, 3), 1) * 1 + Left(Right(Range("Testfeld!A3").Value, 2), 1) * 3 + Left(Right(Range("Testfeld!A3").Value, 1), 1) * 1, 1)
Art7 = 10 - Right(Left(Sheets("Testfeld").Cells(2, 1).Offset(Y, 0).Value, 1) * 3 + Left(Right(Sheets("Testfeld").Cells(2, 1).Offset(Y, 0).Value, 7), 1) * 1 + Left(Right(Sheets("Testfeld").Cells(2, 1).Offset(Y, 0).Value, 6), 1) * 3 + Left(Right(Sheets("Testfeld").Cells(2, 1).Offset(Y, 0).Value, 5), 1) * 1 + Left(Right(Sheets("Testfeld").Cells(2, 1).Offset(Y, 0).Value, 4), 1) * 3 + Left(Right(Sheets("Testfeld").Cells(2, 1).Offset(Y, 0).Value, 3), 1) * 1 + Left(Right(Sheets("Testfeld").Cells(2, 1).Offset(Y, 0).Value, 2), 1) * 3 + Left(Right(Sheets("Testfeld").Cells(2, 1).Offset(Y, 0).Value, 1), 1) * 1, 1)
Debug.Print "Anfang"
Debug.Print Art1
Debug.Print Art2
Debug.Print Art3
Debug.Print Art4
Debug.Print Art5
Debug.Print Art6
Debug.Print Art7
Debug.Print "Ende"
' Generierung Barcode einer Zeile
' Startcodon
Sheets("Testfeld").Cells(2, 2).Offset(Y, 0) = 1
Sheets("Testfeld").Cells(2, 3).Offset(Y, 0) = 0
Sheets("Testfeld").Cells(2, 4).Offset(Y, 0) = 1
Sheets("Testfeld").Cells(2, 5).Offset(Y, 0) = 0
' Barcode aus Artikelnummer
For x = 0 To 13
Sheets("Testfeld").Cells(2, 6).Offset(Y, x) = Left(Sheets("Codierung").Cells(Art1 + 1, 4).Offset(Y, x).Value, 1)
Next x
For x = 0 To 13
Sheets("Testfeld").Cells(2, 20).Offset(Y, x) = Left(Sheets("Codierung").Cells(Art2 + 1, 4).Offset(Y, x).Value, 1)
Next x
For x = 0 To 13
Sheets("Testfeld").Cells(2, 34).Offset(Y, x) = Left(Sheets("Codierung").Cells(Art3 + 1, 4).Offset(Y, x).Value, 1)
Next x
For x = 0 To 13
Sheets("Testfeld").Cells(2, 48).Offset(Y, x) = Left(Sheets("Codierung").Cells(Art4 + 1, 4).Offset(Y, x).Value, 1)
Next x
For x = 0 To 13
Sheets("Testfeld").Cells(2, 62).Offset(Y, x) = Left(Sheets("Codierung").Cells(Art5 + 1, 4).Offset(Y, x).Value, 1)
Next x
For x = 0 To 13
Sheets("Testfeld").Cells(2, 76).Offset(Y, x) = Left(Sheets("Codierung").Cells(Art6 + 1, 4).Offset(Y, x).Value, 1)
Next x
For x = 0 To 13
Sheets("Testfeld").Cells(2, 90).Offset(Y, x) = Left(Sheets("Codierung").Cells(Art7 + 1, 4).Offset(Y, x).Value, 1)
Next x
' Endcodon
Sheets("Testfeld").Cells(2, 104).Offset(Y, 0) = 1
Sheets("Testfeld").Cells(2, 105).Offset(Y, 0) = 1
Sheets("Testfeld").Cells(2, 106).Offset(Y, 0) = 0
Sheets("Testfeld").Cells(2, 107).Offset(Y, 0) = 1
Next Y
End Sub
|