Excel中用VB腳本處理多表數據格式轉換問題
阿新 • • 發佈:2017-07-01
excel vba
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
本文出自 “熔 巖” 博客,請務必保留此出處http://lavasoft.blog.51cto.com/62575/1943631
Excel中用VB腳本處理多表數據格式轉換問題