teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

コード追記

2021/01/11 07:46

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -18,8 +18,21 @@
18
18
  Application.CutCopyMode = False
19
19
  End With
20
20
  ```
21
+ **別案1**
22
+ 配列に連続値を入力しておいて、セル範囲に代入
23
+ ```vba
24
+ Dim v(), i As Long, cnt As Long
25
+ ReDim v(12 To EROW, 1 To 1)
26
+ cnt = Cells(11, 1).Value
27
+ For i = 12 To EROW
28
+ cnt = cnt + 1
29
+ v(i, 1) = cnt
30
+ Next
31
+ Range(Cells(12, 1), Cells(EROW, 1)).Value = v
32
+ ```
21
33
 
34
+
22
- **別案**
35
+ **別案2**
23
36
  加算する式を設定して、値に変換。
24
37
  ```vba
25
38
  With Range(Cells(12, 1), Cells(EROW, 1))

2

コード追記

2021/01/11 07:45

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -17,4 +17,13 @@
17
17
  .PasteSpecial Paste:=xlPasteFormats
18
18
  Application.CutCopyMode = False
19
19
  End With
20
+ ```
21
+
22
+ **別案**
23
+ 加算する式を設定して、値に変換。
24
+ ```vba
25
+ With Range(Cells(12, 1), Cells(EROW, 1))
26
+ .Formula = "=A11+1"
27
+ .Value = .Value
28
+ End With
20
29
  ```

1

コード追記

2021/01/11 07:34

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -1,7 +1,20 @@
1
1
  下記でどうでしょう。
2
2
 
3
3
  ```vba
4
- Cells(1, 1).AutoFill Destination:=Range(Cells(1, 1), Cells(EROW, 1)), Type:=xlLinearTrend
4
+ Cells(11, 1).AutoFill Destination:=Range(Cells(11, 1), Cells(EROW, 1)), Type:=xlLinearTrend
5
- Range(Cells(2, 1), Cells(EROW, 1)).Interior.ColorIndex = 0 '背景色をクリア
5
+ Range(Cells(12, 1), Cells(EROW, 1)).Interior.ColorIndex = 0 '背景色をクリア
6
- 'Range(Cells(2, 1), Cells(EROW, 1)).ClearFormats 'すべての書式をクリアする場合はこちら
6
+ 'Range(Cells(12, 1), Cells(EROW, 1)).ClearFormats 'すべての書式をクリアする場合はこちら
7
+ ```
8
+
9
+ 追記
10
+ ---
11
+
12
+ AutoFill後に右の列を書式をコピーする
13
+ ```vba
14
+ Cells(11, 1).AutoFill Destination:=Range(Cells(11, 1), Cells(EROW, 1)), Type:=xlLinearTrend
15
+ With Range(Cells(12, 1), Cells(EROW, 1))
16
+ .Offset(0, 1).Copy
17
+ .PasteSpecial Paste:=xlPasteFormats
18
+ Application.CutCopyMode = False
19
+ End With
7
20
  ```