|
楼主 |
发表于 2023-3-9 09:51
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
我把这个代码从5列改成11列,会提示错误:“输入超出文件尾”,请教怎么修改啊
Dim r%, i%
Dim arr, brr(1 To 1000, 1 To 11)
Dim mypath$, myname$
Dim reg As Object
Set reg = CreateObject("vbscript.regexp")
With reg
.Global = True
.Pattern = "realvalue=""([^""]+)"
End With
mypath = ThisWorkbook.Path & "\"
myname = "文本数据.txt"
If Dir(mypath & myname) <> "" Then
Open mypath & myname For Input As #1
ss = StrConv(InputB(LOF(1), 1), vbUnicode) '这句报错输入超出文件尾
Set mh = reg.Execute(ss)
m = 1
n = 1
For i = 0 To mh.Count - 1
brr(m, n) = mh(i).SubMatches(0)
n = n + 1
If n > 11 Then
m = m + 1
n = 1
End If
Next
Close #1
End If
With Worksheets("sheet1")
.Columns("a:c").NumberFormatLocal = "@"
.Range("a1").Resize(m, UBound(brr, 2)) = brr
End With |
|