Excel中用VB脚本处理多表数据格式转换问题
Sub pldy() Dim a As Integer Dim b As Integer Dim K As Integer Dim L As Integer a = InputBox("请输入开始打印序号") b = InputBox("请输入结束打印序号") For i = a To b L = (((i + 3) \ 4) - 1) * 7 + 2 If i Mod 4 = 0 Then K = 11 ElseIf i Mod 4 = 3 Then K = 8 ElseIf i Mod 4 = 2 Then K = 5 ElseIf i Mod 4 = 1 Then K = 2 End If 'MsgBox ("i=" & i & Chr(13) & Chr(10) + "L=" & L & Chr(13) & Chr(10) + "K=" & K)' Sheets("标签打印").Cells(L, K) = Sheets("资产明细").Range("d" & i + 1) Sheets("标签打印").Cells(L + 1, K) = Sheets("资产明细").Range("b" & i + 1) Sheets("标签打印").Cells(L + 2, K) = Sheets("资产明细").Range("i" & i + 1) Sheets("标签打印").Cells(L + 3, K) = Sheets("资产明细").Range("k" & i + 1) Sheets("标签打印").Cells(L + 4, K) = Sheets("资产明细").Range("g" & i + 1) If Int(i / 36) = (i / 36) Then ActiveSheet.PrintOut End If Next i End Sub
没学过VB,现学现卖O(∩_∩)O