回答編集履歴

1

追記

2015/10/20 10:15

投稿

tomo.ina
tomo.ina

スコア357

test CHANGED
@@ -11,3 +11,145 @@
11
11
  マクロでもできますが、上から順に表示するだけであれば、
12
12
 
13
13
  他の方の回答のように式をいれるのが一番簡単かと思います。
14
+
15
+
16
+
17
+ ![イメージ説明](586bb12b6362b643b4bd4b73d46e9359.png)
18
+
19
+ 左のシートを「print」、右のシートを「data」と過程して、標準モジュールに以下のような
20
+
21
+ マクロを作成しました。
22
+
23
+ 動くことだけしか確認していないので汚いソースですいません…
24
+
25
+
26
+
27
+ 出力する新規月を「2」で固定していますが、実際は汎用的に処理できるように
28
+
29
+ したほうがよいと思います。
30
+
31
+
32
+
33
+ Option Explicit
34
+
35
+
36
+
37
+ '/ Sheet名
38
+
39
+ Private Const cpSheetPrint As String = "print"
40
+
41
+ Private Const cpSheetData As String = "data"
42
+
43
+
44
+
45
+ '/ 各Sheetの処理開始行
46
+
47
+ Private Const cpStartRowPrint As Long = 4
48
+
49
+ Private Const cpStartRowData As Long = 2
50
+
51
+
52
+
53
+ '/ ◆列定数(printシート)
54
+
55
+ Private Const cpColPrt_No As Long = 1
56
+
57
+ Private Const cpColPrt_Name As Long = 2
58
+
59
+ Private Const cpColPrt_adress As Long = 3
60
+
61
+
62
+
63
+ '/ ◆列定数(dataシート)
64
+
65
+ Private Const cpColDat_No As Long = 1
66
+
67
+ Private Const cpColDat_Name As Long = 2
68
+
69
+ Private Const cpColDat_adress As Long = 3
70
+
71
+ Private Const cpColDat_Month As Long = 4
72
+
73
+ Private Const cpColDat_Flg As Long = 5
74
+
75
+
76
+
77
+ '/出力する明細の記号
78
+
79
+ Private Const cpMark As String = "○"
80
+
81
+
82
+
83
+ Public Sub Out_Data()
84
+
85
+
86
+
87
+ Dim plRowMax As Long
88
+
89
+ Dim plDataRow As Long
90
+
91
+ Dim plPrintRow As Long
92
+
93
+ Dim plDataSheet As Worksheet
94
+
95
+ Dim plPrintSheet As Worksheet
96
+
97
+
98
+
99
+ '/ワークシートのセット
100
+
101
+ Set plDataSheet = ThisWorkbook.Sheets(cpSheetData)
102
+
103
+ Set plPrintSheet = ThisWorkbook.Sheets(cpSheetPrint)
104
+
105
+
106
+
107
+ '/dataシートの最終行セット
108
+
109
+ plRowMax = plDataSheet.Range("A65536").End(xlUp).Row
110
+
111
+ plPrintRow = cpStartRowPrint
112
+
113
+
114
+
115
+
116
+
117
+ For plDataRow = cpStartRowData To plRowMax
118
+
119
+
120
+
121
+ '/出力判定
122
+
123
+ If plDataSheet.Cells(plDataRow, cpColDat_Month).Value = 2 And _
124
+
125
+ plDataSheet.Cells(plDataRow, cpColDat_Flg).Value = cpMark Then
126
+
127
+
128
+
129
+ plPrintSheet.Cells(plPrintRow, cpColPrt_No).Value = plDataSheet.Cells(plDataRow, cpColDat_No).Value
130
+
131
+ plPrintSheet.Cells(plPrintRow, cpColPrt_Name).Value = plDataSheet.Cells(plDataRow, cpColDat_Name).Value
132
+
133
+ plPrintSheet.Cells(plPrintRow, cpColPrt_adress).Value = plDataSheet.Cells(plDataRow, cpColDat_adress).Value
134
+
135
+
136
+
137
+ plPrintRow = plPrintRow + 1
138
+
139
+
140
+
141
+ End If
142
+
143
+
144
+
145
+ Next plDataRow
146
+
147
+
148
+
149
+ Exit Sub
150
+
151
+
152
+
153
+ End Sub
154
+
155
+