Sub 生成卡片() Dim a As Range, dr As Range Set dd = Sheets("需要打印的清单") Set bb = Sheets("卡片") lr = dd.[a65536].End(xlUp).Row Set dr = Range(dd.Cells(2, 1), dd.Cells(lr, 1)) p = 1 For Each a In dr With a If Cells(p, 1) = Empty Then For i = 2 To 5 bb.Cells(p, 1) = " " bb.Cells(p + i - 1, 1) = "_________" & .Offset(0, i - 1).Value bb.Cells(p + 5, 1) = "_________" & .Value '原来我那语句放这里了 Next i ElseIf Cells(p, 3) = Empty Then For i = 1 To 4 bb.Cells(p, 3) = " " bb.Cells(p + i, 3) = "_________" & .Offset(0, i).Value bb.Cells(p + 5, 3) = "_________" & .Value Next i Else p = p + 7 For i = 2 To 5 bb.Cells(p, 1) = " " bb.Cells(p + i - 1, 1) = "_________" & .Offset(0, i - 1).Value bb.Cells(p + 5, 1) = "_________" & .Value Next i End If End With Next lr2 = bb.[a65536].End(xlUp).Row For j = 1 To 3 Step 2 For i = 2 To lr2 If Len(bb.Cells(i, j)) > 9 Then bb.Cells(i, j).Characters(1, 9).Font.ColorIndex = 2 bb.Cells(i, j).WrapText = False Else End If Next i Next j End Sub 这个版本是已经修改好的了,呵呵 |