回答編集履歴

2

コード修正

2021/03/01 13:04

投稿

hatena19
hatena19

スコア34073

test CHANGED
@@ -4,17 +4,17 @@
4
4
 
5
5
  Sub Filter()
6
6
 
7
- Dim ws As Worksheet, c As Range, i As long, rs As Long
7
+ Dim ws As Worksheet, c As Range, i As Long, h As Long
8
8
 
9
- i = 1, rs=3
9
+ i = 1: h = 3
10
10
 
11
- Set ws = Worksheets("元CSV")
11
+ Set ws = Worksheets("元CSV")
12
12
 
13
13
  For Each c In ws.Cells.SpecialCells(xlCellTypeConstants).Areas
14
14
 
15
- c.Resize(rs).Copy Destination:=Worksheets("Sheet1").Range("A" & i)
15
+ c.Resize(h).Copy Destination:=Worksheets("Sheet2").Range("A" & i)
16
16
 
17
- i = i + 3: rs = 2
17
+ i = i + h + 1: h = 2
18
18
 
19
19
  Next
20
20
 

1

コード修正

2021/03/01 13:04

投稿

hatena19
hatena19

スコア34073

test CHANGED
@@ -4,17 +4,17 @@
4
4
 
5
5
  Sub Filter()
6
6
 
7
- Dim ws As Worksheet, c As Range, i As Integer
7
+ Dim ws As Worksheet, c As Range, i As long, rs As Long
8
8
 
9
- i = 1
9
+ i = 1, rs=3
10
10
 
11
11
  Set ws = Worksheets("元CSV")
12
12
 
13
13
  For Each c In ws.Cells.SpecialCells(xlCellTypeConstants).Areas
14
14
 
15
- c.Resize(2).Copy Destination:=Worksheets("Sheet1").Range("A" & i)
15
+ c.Resize(rs).Copy Destination:=Worksheets("Sheet1").Range("A" & i)
16
16
 
17
- i = i + 3
17
+ i = i + 3: rs = 2
18
18
 
19
19
  Next
20
20