|
これでどうかな ?
Sub Check_Comma()
Dim i As Long
Dim MyF As String, Buf As String
Dim Ary As Variant
Dim RExp As Object, Matches As Object
MyF = Application _
.GetOpenFilename("CSVファイル(*.csv),*.csv")
If MyF = "False" Then Exit Sub
Range("A:B").ClearContents: i = 1
Range("A1:B1").Value = Array("項目1", "カンマ数")
Set RExp = CreateObject("VBScript.RegExp")
With RExp
.Pattern = "(,)"
.Global = True
End With
Open MyF For Input Access Read As #1
Do Until EOF(1)
Line Input #1, Buf
Set Matches = RExp.Execute(Buf)
Ary = Split(Buf, ","): i = i + 1
Cells(i, 1).Value = Ary(0)
Cells(i, 2).Value = Matches.Count
Set Matches = Nothing
Loop
Close #1: Set RExp = Nothing
End Sub
|
|