回答編集履歴
1
追記
test
CHANGED
@@ -19,3 +19,41 @@
|
|
19
19
|
|
20
20
|
|
21
21
|
```
|
22
|
+
|
23
|
+
---
|
24
|
+
|
25
|
+
<追記>
|
26
|
+
|
27
|
+
元のセル値に関わらず全てのセルをダブルクォーテーションで括るのがお望みだったでしょうか。
|
28
|
+
|
29
|
+
考えてみましたが今一つスッキリと書けませんでした。
|
30
|
+
|
31
|
+
```VBA
|
32
|
+
|
33
|
+
Function makeCSV(ws As Worksheet)
|
34
|
+
|
35
|
+
Const wxw = """*""", x = "*"
|
36
|
+
|
37
|
+
With ws.UsedRange
|
38
|
+
|
39
|
+
Dim r, c, i, j, t
|
40
|
+
|
41
|
+
r = .Rows.Count: c = .Columns.Count
|
42
|
+
|
43
|
+
ReDim arr(1 To r, 1 To c)
|
44
|
+
|
45
|
+
For i = 1 To r: For j = 1 To c
|
46
|
+
|
47
|
+
t = .Cells(i, j).Text
|
48
|
+
|
49
|
+
arr(i, j) = IIf(t Like wxw, t, Replace(wxw, x, t))
|
50
|
+
|
51
|
+
Next j, i
|
52
|
+
|
53
|
+
makeCSV = WorksheetFunction.TextJoin(Split(WorksheetFunction.Rept(", ", c - 1) & vbLf), False, arr)
|
54
|
+
|
55
|
+
End With
|
56
|
+
|
57
|
+
End Function
|
58
|
+
|
59
|
+
```
|