VBA列表将被放入贴纸格式

我有一个需要打印出来的数据列表(想象一下Averytypes)。 我有麻烦提出的代码将产生所需的结果:

我的代码到目前为止是:

With wsEtiketten ' erase old data .Cells.Clear ' enter new data With .Cells(1, 2) .Value = "Lettrine" .Font.Bold = True End With .Cells(2, 2).Value = sAuswertungsLettrine For i = 0 To MaxRow - 1 For j = 0 To 4 r.Copy .Cells(4, 2).Offset(i * 5, j * 5) .Cells(4, 2).Offset((i * 5) + 1, (j * 5) + 0) = wsSheet.ListObjects(1).DataBodyRange.Cells(i + 1, 1).Value 'Page .Cells(4, 2).Offset((i * 5) + 1, (j * 5) + 1) = wsSheet.ListObjects(1).DataBodyRange.Cells(i + 1, 2).Value 'Ordernr .Cells(4, 2).Offset((i * 5) + 1, (j * 5) + 2) = wsSheet.ListObjects(1).DataBodyRange.Cells(i + 1, 8).Value 'Surf .Cells(4, 2).Offset((i * 5) + 1, (j * 5) + 3) = wsSheet.ListObjects(1).DataBodyRange.Cells(i + 1, 9).Value 'Indice DB .Cells(4, 2).Offset((i * 5) + 3, (j * 5) + 0) = wsSheet.ListObjects(1).DataBodyRange.Cells(i + 1, 3).Value 'Count .Cells(4, 2).Offset((i * 5) + 3, (j * 5) + 1) = wsSheet.ListObjects(1).DataBodyRange.Cells(i + 1, 4).Value 'CA Brut .Cells(4, 2).Offset((i * 5) + 3, (j * 5) + 3) = wsSheet.ListObjects(1).DataBodyRange.Cells(i + 1, 7).Value 'Marge Next j Next i End With 

与之相关的信息只是在整个行中重复。 每当这个字段被抵消的时候,我都需要改变它。 我怎样才能做到这一点? 我确定这可能是编程幼儿园的东西,但我没有得到它。

谢谢!

也许是一个意想不到的转折。 您可以结合Word使用Excel表格来获得所需的结果。 这是标准的Officefunction:

http://support.microsoft.com/kb/318117/en

或用德语:

http://support.microsoft.com/kb/318117/de

好。 我设法在Excel中提出了一个答案。 一旦我有了它,这是显而易见的。 开始:

 With wsEtiketten ' Alte Daten werden gelöscht .Cells.Clear ' Neue Daten werden eingelesen With .Cells(1, 2) .Value = "Lettrine" .Font.Bold = True End With .Cells(2, 2).Value = sAuswertungsLettrine For i = 0 To MaxRow - 1 r.Copy .Cells(4, 2).Offset(WorksheetFunction.RoundDown(i / 5, 0) * 5, ((i + 5) Mod 5) * 5) .Cells(4, 2).Offset((WorksheetFunction.RoundDown(i / 5, 0)) * 5 + 1, ((i + 5) Mod 5) * 5 + 0) = wsSheet.ListObjects(1).DataBodyRange.Cells(i + 1, 1).Value 'Page .Cells(4, 2).Offset((WorksheetFunction.RoundDown(i / 5, 0)) * 5 + 1, ((i + 5) Mod 5) * 5 + 1) = wsSheet.ListObjects(1).DataBodyRange.Cells(i + 1, 2).Value 'Bestellnummer .Cells(4, 2).Offset((WorksheetFunction.RoundDown(i / 5, 0)) * 5 + 1, ((i + 5) Mod 5) * 5 + 2) = wsSheet.ListObjects(1).DataBodyRange.Cells(i + 1, 8).Value 'Surf .Cells(4, 2).Offset((WorksheetFunction.RoundDown(i / 5, 0)) * 5 + 1, ((i + 5) Mod 5) * 5 + 3) = wsSheet.ListObjects(1).DataBodyRange.Cells(i + 1, 9).Value 'Indice DB .Cells(4, 2).Offset((WorksheetFunction.RoundDown(i / 5, 0)) * 5 + 3, ((i + 5) Mod 5) * 5 + 0) = wsSheet.ListObjects(1).DataBodyRange.Cells(i + 1, 3).Value 'Anzahl .Cells(4, 2).Offset((WorksheetFunction.RoundDown(i / 5, 0)) * 5 + 3, ((i + 5) Mod 5) * 5 + 1) = wsSheet.ListObjects(1).DataBodyRange.Cells(i + 1, 4).Value 'CA Brut .Cells(4, 2).Offset((WorksheetFunction.RoundDown(i / 5, 0)) * 5 + 3, ((i + 5) Mod 5) * 5 + 3) = wsSheet.ListObjects(1).DataBodyRange.Cells(i + 1, 7).Value 'Marge Next i End With