Excel中用VB脚本处理多表数据格式转换问题
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
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
本文转自 leizhimin 51CTO博客,原文链接:http://blog.51cto.com/lavasoft/1943631,如需转载请自行联系原作者