質問編集履歴

2

変更点:変数の型をworksheet型からstring型に変更し、ws.name=を代入

2021/06/10 00:31

投稿

robben
robben

スコア12

test CHANGED
File without changes
test CHANGED
@@ -98,7 +98,15 @@
98
98
 
99
99
 
100
100
 
101
-
101
+ Worksheets(ary200).Select
102
+
103
+ ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Users\awga1\Documents\PDF保管\200.pdf"
104
+
105
+
106
+
107
+ Worksheets(ary300).Select
108
+
109
+ ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Users\awga1\Documents\PDF保管\300.pdf"
102
110
 
103
111
  End Sub
104
112
 

1

①変数をworksheet型 から string型に変更②変数の型変更に伴い、変数には、worksheetではなく、worksheet.nameを代入

2021/06/10 00:31

投稿

robben
robben

スコア12

test CHANGED
File without changes
test CHANGED
@@ -36,19 +36,19 @@
36
36
 
37
37
 
38
38
 
39
- Dim ary100() As Worksheet
39
+ Dim ary100() As String
40
40
 
41
- Dim ary200() As Worksheet
41
+ Dim ary200() As String
42
42
 
43
- Dim ary300() As Worksheet
43
+ Dim ary300() As String
44
44
 
45
45
 
46
46
 
47
- ReDim ary100(1 To 1) As Worksheet
47
+ ReDim ary100(1 To 1) As String
48
48
 
49
- ReDim ary200(1 To 1) As Worksheet
49
+ ReDim ary200(1 To 1) As String
50
50
 
51
- ReDim ary300(1 To 1) As Worksheet
51
+ ReDim ary300(1 To 1) As String
52
52
 
53
53
 
54
54
 
@@ -62,25 +62,27 @@
62
62
 
63
63
  Case 100
64
64
 
65
- Set ary100(UBound(ary100)) = ws
65
+ ary100(UBound(ary100)) = ws.Name
66
66
 
67
+
68
+
67
- ReDim Preserve ary100(1 To UBound(ary100) + 1) As Worksheet
69
+ ReDim Preserve ary100(1 To UBound(ary100) + 1)
68
70
 
69
71
 
70
72
 
71
73
  Case 200
72
74
 
73
- Set ary200(UBound(ary200)) = ws
75
+ ary200(UBound(ary200)) = ws.Name
74
76
 
75
- ReDim Preserve ary200(1 To UBound(ary200) + 1) As Worksheet
77
+ ReDim Preserve ary200(1 To UBound(ary200) + 1)
76
78
 
77
79
 
78
80
 
79
81
  Case 300
80
82
 
81
- Set ary300(UBound(ary300)) = ws
83
+ ary300(UBound(ary300)) = ws.Name
82
84
 
83
- ReDim Preserve ary300(1 To UBound(ary300) + 1) As Worksheet
85
+ ReDim Preserve ary300(1 To UBound(ary300) + 1)
84
86
 
85
87
 
86
88
 
@@ -88,11 +90,11 @@
88
90
 
89
91
  Next
90
92
 
91
- ary100().ExportAsFixedFormat Type:=0, Filename:="C:\Users\awga1\Documents\PDF保管\100.pdf"
92
93
 
93
- ary200().ExportAsFixedFormat Type:=0, Filename:="C:\Users\awga1\Documents\PDF保管\200.pdf"
94
94
 
95
+ Worksheets(ary100).Select
96
+
95
- ary300().ExportAsFixedFormat Type:=0, Filename:="C:\Users\awga1\Documents\PDF保管\300.pdf"
97
+ ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Users\awga1\Documents\PDF保管\100.pdf"
96
98
 
97
99
 
98
100
 
@@ -102,4 +104,10 @@
102
104
 
103
105
 
104
106
 
107
+
108
+
109
+
110
+
111
+
112
+
105
113
  ```