質問編集履歴
2
変更点:変数の型をworksheet型からstring型に変更し、ws.name=を代入
title
CHANGED
File without changes
|
body
CHANGED
@@ -48,7 +48,11 @@
|
|
48
48
|
Worksheets(ary100).Select
|
49
49
|
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Users\awga1\Documents\PDF保管\100.pdf"
|
50
50
|
|
51
|
-
|
51
|
+
Worksheets(ary200).Select
|
52
|
+
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Users\awga1\Documents\PDF保管\200.pdf"
|
53
|
+
|
54
|
+
Worksheets(ary300).Select
|
55
|
+
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Users\awga1\Documents\PDF保管\300.pdf"
|
52
56
|
End Sub
|
53
57
|
|
54
58
|
|
1
①変数をworksheet型 から string型に変更②変数の型変更に伴い、変数には、worksheetではなく、worksheet.nameを代入
title
CHANGED
File without changes
|
body
CHANGED
@@ -17,37 +17,41 @@
|
|
17
17
|
コード
|
18
18
|
Sub macro()
|
19
19
|
|
20
|
-
Dim ary100() As
|
20
|
+
Dim ary100() As String
|
21
|
-
Dim ary200() As
|
21
|
+
Dim ary200() As String
|
22
|
-
Dim ary300() As
|
22
|
+
Dim ary300() As String
|
23
23
|
|
24
|
-
ReDim ary100(1 To 1) As
|
24
|
+
ReDim ary100(1 To 1) As String
|
25
|
-
ReDim ary200(1 To 1) As
|
25
|
+
ReDim ary200(1 To 1) As String
|
26
|
-
ReDim ary300(1 To 1) As
|
26
|
+
ReDim ary300(1 To 1) As String
|
27
27
|
|
28
28
|
Dim ws As Worksheet
|
29
29
|
For Each ws In Sheets
|
30
30
|
|
31
31
|
Select Case Left(ws.Name, 3)
|
32
32
|
Case 100
|
33
|
-
|
33
|
+
ary100(UBound(ary100)) = ws.Name
|
34
|
+
|
34
|
-
ReDim Preserve ary100(1 To UBound(ary100) + 1)
|
35
|
+
ReDim Preserve ary100(1 To UBound(ary100) + 1)
|
35
36
|
|
36
37
|
Case 200
|
37
|
-
|
38
|
+
ary200(UBound(ary200)) = ws.Name
|
38
|
-
ReDim Preserve ary200(1 To UBound(ary200) + 1)
|
39
|
+
ReDim Preserve ary200(1 To UBound(ary200) + 1)
|
39
40
|
|
40
41
|
Case 300
|
41
|
-
|
42
|
+
ary300(UBound(ary300)) = ws.Name
|
42
|
-
ReDim Preserve ary300(1 To UBound(ary300) + 1)
|
43
|
+
ReDim Preserve ary300(1 To UBound(ary300) + 1)
|
43
44
|
|
44
45
|
End Select
|
45
46
|
Next
|
47
|
+
|
48
|
+
Worksheets(ary100).Select
|
46
|
-
|
49
|
+
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Users\awga1\Documents\PDF保管\100.pdf"
|
47
|
-
ary200().ExportAsFixedFormat Type:=0, Filename:="C:\Users\awga1\Documents\PDF保管\200.pdf"
|
48
|
-
ary300().ExportAsFixedFormat Type:=0, Filename:="C:\Users\awga1\Documents\PDF保管\300.pdf"
|
49
50
|
|
50
51
|
|
51
52
|
End Sub
|
52
53
|
|
54
|
+
|
55
|
+
|
56
|
+
|
53
57
|
```
|