Option Explicit Sub generatePWM1() Dim arr As String arr = "Const" & vbCrLf arr = arr & "pwmcount : Byte = " & ActiveSheet.Cells(2, 7).Value & ";" & vbCrLf arr = arr & "pwmtable_a : Array[0.." & ActiveSheet.Cells(2, 7).Value & "] of Byte = (" & vbCrLf & " " Dim rRng As Range Set rRng = ActiveSheet.Range("$B$3:$B$258") Dim rCell As Range Dim i As Integer i = 1 Dim objData As New MSForms.DataObject For Each rCell In rRng.Cells If rCell.Value <= ActiveSheet.Cells(1, 7).Value Then If i = 10 Then arr = arr & "$" & Hex(rCell.Value) & ", " & vbCrLf & " " i = 1 Else arr = arr & "$" & Hex(rCell.Value) & ", " i = i + 1 End If End If If rCell.Row = ActiveSheet.Cells(2, 7).Value + 2 Then arr = arr & "$" & Hex(rCell.Value) & ");" & vbCrLf Debug.Print rCell End If Next rCell objData.SetText (arr) objData.PutInClipboard MsgBox ("Das Ergebis wurde in die Zwischenablge kopiert") End Sub Sub generatePWM2() Dim arr As String Rem arr = "static const uint8_t pwmtable[] PROGMEM = {" arr = "Const" & vbCrLf arr = arr & "pwmcount : Byte = " & ActiveSheet.Cells(2, 7).Value & ";" & vbCrLf arr = arr & "pwmtable_b : Array[0.." & ActiveSheet.Cells(2, 7).Value & "] of Byte = (" & vbCrLf & " " Dim rRng As Range Set rRng = ActiveSheet.Range("$C$3:$C$258") Dim rCell As Range Dim i As Integer i = 1 Dim objData As New MSForms.DataObject For Each rCell In rRng.Cells If rCell.Value <= ActiveSheet.Cells(1, 7).Value Then If i = 10 Then arr = arr & "$" & Hex(rCell.Value) & ", " & vbCrLf & " " Rem arr = arr & rCell.Value & ", " & vbCrLf i = 1 Else arr = arr & "$" & Hex(rCell.Value) & ", " Rem arr = arr & rCell.Value & ", " i = i + 1 End If End If If rCell.Row = ActiveSheet.Cells(2, 7).Value + 2 Then arr = arr & "$" & Hex(rCell.Value) & ");" & vbCrLf Rem arr = arr & rCell.Value & "};" & vbCrLf Debug.Print rCell End If Next rCell objData.SetText (arr) objData.PutInClipboard MsgBox ("Das Ergebis wurde in die Zwischenablge kopiert") End Sub Sub generatePWM3() Dim arr As String arr = "Const" & vbCrLf arr = arr & "pwmcount : Byte = " & ActiveSheet.Cells(2, 7).Value & ";" & vbCrLf arr = arr & "pwmtable_c : Array[0.." & ActiveSheet.Cells(2, 7).Value & "] of Byte = (" & vbCrLf & " " Rem arr = "static const uint8_t pwmtable[] PROGMEM = {" Dim rRng As Range Set rRng = ActiveSheet.Range("$D$3:$D$258") Dim rCell As Range Dim i As Integer i = 1 Dim objData As New MSForms.DataObject For Each rCell In rRng.Cells If rCell.Value <= ActiveSheet.Cells(1, 7).Value Then If i = 10 Then arr = arr & "$" & Hex(rCell.Value) & ", " & vbCrLf & " " Rem arr = arr & rCell.Value & ", " & vbCrLf i = 1 Else arr = arr & "$" & Hex(rCell.Value) & ", " Rem arr = arr & rCell.Value & ", " i = i + 1 End If End If If rCell.Row = ActiveSheet.Cells(2, 7).Value + 2 Then arr = arr & "$" & Hex(rCell.Value) & ");" & vbCrLf Rem arr = arr & rCell.Value & "};" & vbCrLf Debug.Print rCell End If Next rCell objData.SetText (arr) objData.PutInClipboard MsgBox ("Das Ergebis wurde in die Zwischenablge kopiert") End Sub