回答編集履歴

1

コード追記

2017/01/04 01:27

投稿

ynakano
ynakano

スコア1894

test CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  範囲を選択して
4
4
 
5
+ ```
6
+
5
- ```Selection.Replace What:="", Replacement:="-"```
7
+ Selection.Replace What:="", Replacement:="-"
8
+
9
+ ```
6
10
 
7
11
  でOKかと。
8
12
 
@@ -15,3 +19,49 @@
15
19
  これを変数で受ければOKです。
16
20
 
17
21
  ※上記はA列の末尾を探す記述になっています。
22
+
23
+
24
+
25
+ 追記
26
+
27
+ ---
28
+
29
+ 左側のかたまりの部分についてコードを書いてみました。
30
+
31
+ ちょっと泥臭い書き方で、かつ一部決め打ちの部分があります。
32
+
33
+ ```
34
+
35
+ Sub test()
36
+
37
+ Dim curMax As Integer
38
+
39
+ Dim totalMax As Integer
40
+
41
+ Dim myArray1() As Variant
42
+
43
+
44
+
45
+ myArray1 = Array("C", "D", "E")
46
+
47
+
48
+
49
+ For Each TG In myArray1
50
+
51
+ curMax = Cells(Rows.Count, TG).End(xlUp).Row
52
+
53
+
54
+
55
+ If (curMax > totalMax) Then totalMax = curMax
56
+
57
+ Next
58
+
59
+
60
+
61
+ Range("C3:E" & totalMax).Replace What:="", Replacement:="-"
62
+
63
+ End Sub
64
+
65
+ ```
66
+
67
+