プロが教える店舗&オフィスのセキュリティ対策術

このマクロなんですが、Sent_88310.emlを1列で表示したいのですが、ここにあるように
myFields = Split(inRec, ",") カンマで区切られて、2列になってしまいます1列にしたく、
いろいろ、やってみますが、構文エラーになったり、うまく動きません。
どんなふうに、修正したらいいのでしょうか?

---------------------
Public Sub ReadCSV()
'CSVファイルの読み込み

Dim n As Long
Dim myFields As Variant
Dim inRec As String
Dim r As Long
Dim c As Long

n = FreeFile
Open ThisWorkbook.Path & "\Sent_88310.eml" For Input As #n
r = 1
Do While Not EOF(n)
Line Input #n, inRec
myFields = Split(inRec, ",")
For c = 0 To UBound(myFields)
Cells(r, c + 1).Value = myFields(c)
Next c
r = r + 1
Loop
Close #n
End Sub
---------------------------

A 回答 (1件)

こんばんは



>カンマで区切られて、2列になってしまいます1列にしたく、~
そのまま1セルに入れたいってことでしょうか?
それなら、カンマで分割しなければよいだけでは?

Do While Not EOF(n)
Line Input #n, inRec
'myFields = Split(inRec, ",")
'For c = 0 To UBound(myFields)
'Cells(r, c + 1).Value = myFields(c)
'Next c
Cells(r, 1).Value = inRec
r = r + 1
Loop
    • good
    • 0
この回答へのお礼

助かりました

お礼日時:2024/02/16 21:12

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!

このQ&Aを見た人はこんなQ&Aも見ています


このQ&Aを見た人がよく見るQ&A