|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
输出到工作表,使用Transpose函数转置失败,用数组转置吧:- Private Sub CommandButton1_Click()
- Dim F, s$(), arr$(), i&
- F = Application.GetOpenFilename("文本文件(*.txt), *.txt,所有文件(*.*), *.*", , "请单选OMC导出的GSMNCELL邻区表文本") '一次只打开一个文件,参数顺序不能变,第二个是索引留空
- s = Split(ReadUTF(F), vbCrLf)
- ReDim arr(0 To UBound(s), 1 To 1)
- For i = 0 To UBound(s)
- arr(i, 1) = s(i)
- Next
- Cells.ClearContents
- [a1].Resize(i) = arr
- End Sub
- Function ReadUTF(ByVal FileName As String) As String
- With CreateObject("ADODB.Stream")
- .Type = 2 '读取文本文件
- .Mode = 3 '读写
- .Open
- .LoadFromFile FileName
- .Charset = "UTF-8" '设定编码
- .Position = 2
- ReadUTF = .ReadText
- .Close
- End With
- End Function
复制代码 |
评分
-
1
查看全部评分
-
|