|
Option Explicit
Sub test1()
Dim ar, br, cr, i&, j&, tRng As Range, iPosRow&, iMsg&
Application.ScreenUpdating = False
ar = Worksheets("店舗").[B1].CurrentRegion.Value
Set tRng = Sheets("みやき用紙(数式有)").[A1:K31]
br = [{"B1","H1","B18","H18"}]
cr = [{"A5","G5","A22","G22"}]
With Worksheets(3)
.Cells.Delete
For i = 1 To UBound(ar)
iPosRow = (i - 1) * 32 + 1
rngCopyToSame tRng, .Cells(iPosRow, 1)
If i > 1 Then .HPageBreaks.Add Before:=.Cells(iPosRow, 1)
With .Cells(iPosRow, 1)
For j = 1 To UBound(br)
.Range(br(j)).Value = "'" & Format(ar(i, 1), "00000") & Format(Date, "YYMMDD") & Format(j, "0000")
Next j
For j = 1 To UBound(cr)
.Range(cr(j)).Value = ar(i, 2)
.Range(cr(j)).Offset(1).Offset(, 4).Value = ar(i, 1)
Next j
End With
Next i
.Activate
iMsg = MsgBox("是否预览", vbYesNo + vbInformation, "???")
If iMsg = vbYes Then .PrintPreview
ActiveWindow.ScrollRow = 1
End With
Application.ScreenUpdating = True
Beep
End Sub
Function rngCopyToSame(ByVal rngSel As Range, ByVal rngTarget As Range)
Dim i&
rngSel.Copy
rngTarget.PasteSpecial xlPasteColumnWidths
rngSel.Copy rngTarget
With rngTarget.Resize(rngSel.Rows.Count, rngSel.Columns.Count)
For i = 1 To .Rows.Count
.Rows(i).RowHeight = rngSel.Rows(i).RowHeight
Next i
End With
End Function
|
评分
-
2
查看全部评分
-
|