全般
エクセルマクロでエラーが出ます。印刷しようとすると「PageSetu...
エクセルマクロでエラーが出ます。印刷しようとすると「PageSetupクラスのPrintAreaプロパティを設定できません」と表示され「.PageSetup.PrintArea = page(0)」の背景が黄色くなります。 エクセル2003です。 Sub つなぎ3()
Dim 連番, 請求
Dim page(30), z
Dim myFooter, i
Set 連番 = Worksheets("連番")
Set 請求 = Worksheets("請求書")
page(1) = "A1: K49"
page(2) = "A50: K96"
page(3) = "A97: K143"
page(4) = "A144: K190"
page(5) = "A191: K237"
page(6) = "A238: K284"
page(7) = "A285: K331"
page(8) = "A332: K378"
page(9) = "A379: K425"
page(10) = "A426: K472"
page(11) = "A473: K519"
page(12) = "A520: K566"
page(13) = "A567: K613"
page(14) = "A614: K660"
page(15) = "A661: K707"
page(16) = "L1: V49"
page(17) = "L50: V96"
page(18) = "L97: V143"
page(19) = "L144: V190"
page(20) = "L191: V237"
page(21) = "L238: V284"
page(22) = "L285: V331"
page(23) = "L332: V378"
page(24) = "L379: V425"
page(25) = "L426: V472"
page(26) = "L473: V519"
page(27) = "L520: V566"
page(28) = "L567: V613"
page(29) = "L614: V660"
page(30) = "L661: V707"
Select Case 連番.Range("B4").Value
Case Is < 49
page(0) = page(1) & "," & page(16)
z = 2
Case Is < 96
page(0) = page(1) & "," & page(2) & "," & page(16) & "," & page(17)
z = 4
Case Is < 143
page(0) = page(1) & "," & page(2) & "," & page(3) & "," & page(16) & "," & page(17) & "," & page(18)
z = 6
Case Is < 190
page(0) = page(1) & "," & page(2) & "," & page(3) & "," & page(4) & "," & page(16) & "," & page(17) & "," & page(18) & "," & page(19)
z = 8
Case Is < 237
page(0) = page(1) & "," & page(2) & "," & page(3) & "," & page(4) & "," & page(5) & "," & page(16) & "," & page(17) & "," & page(18) & "," & page(19) & "," & page(20)
z = 10
Case Is < 284
page(0) = page(1) & "," & page(2) & "," & page(3) & "," & page(4) & "," & page(5) & "," & page(6) & "," & page(16) & "," & page(17) & "," & page(18) & "," & page(19) & "," & page(20) & "," & page(21)
z = 12
Case Is < 331
page(0) = page(1) & "," & page(2) & "," & page(3) & "," & page(4) & "," & page(5) & "," & page(6) & "," & page(7) & "," & page(16) & "," & page(17) & "," & page(18) & "," & page(19) & "," & page(20) & "," & page(21) & "," & page(22)
z = 14
Case Is < 378
page(0) = page(1) & "," & page(2) & "," & page(3) & "," & page(4) & "," & page(5) & "," & page(6) & "," & page(7) & "," & page(8) & "," & page(16) & "," & page(17) & "," & page(18) & "," & page(19) & "," & page(20) & "," & page(21) & "," & page(22) & "," & page(23)
z = 16
Case Is < 425
page(0) = page(1) & "," & page(2) & "," & page(3) & "," & page(4) & "," & page(5) & "," & page(6) & "," & page(7) & "," & page(8) & "," & page(9) & "," & page(16) & "," & page(17) & "," & page(18) & "," & page(19) & "," & page(20) & "," & page(21) & "," & page(22) & "," & page(23) & "," & page(24)
z = 18
Case Is < 472
page(0) = page(1) & "," & page(2) & "," & page(3) & "," & page(4) & "," & page(5) & "," & page(6) & "," & page(7) & "," & page(8) & "," & page(9) & "," & page(10) & "," & page(16) & "," & page(17) & "," & page(18) & "," & page(19) & "," & page(20) & "," & page(21) & "," & page(22) & "," & page(23) & "," & page(24) & "," & page(25)
z = 20
Case Is < 519
page(0) = page(1) & "," & page(2) & "," & page(3) & "," & page(4) & "," & page(5) & "," & page(6) & "," & page(7) & "," & page(8) & "," & page(9) & "," & page(10) & "," & page(11) & "," & page(16) & "," & page(17) & "," & page(18) & "," & page(19) & "," & page(20) & "," & page(21) & "," & page(22) & "," & page(23) & "," & page(24) & "," & page(25) & "," & page(26)
z = 22
-文字数の関係上省略-
End Select
With Worksheets("顧客")
For i = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
If 請求.Range("C1").Value = .Cells(i, 1).Value Then
myFooter = .Cells(i, "Q").Value
Exit For
End If
Next
End With
With 請求
.PageSetup.CenterFooter = myFooter
.PageSetup.PrintArea = page(0)
.PrintOut From:=1, To:=z, Copies:=1, Collate:=True
End With
Set 連番 = Nothing
Set 請求 = Nothing
End Sub
何が原因でしょうか?
コメントする