Excel用VBA 处理数据 取其中几列的数据以TXT格式存放
时间:2011-09-06
来源:互联网
Excel用VBA 处理数据 取其中几列的数据以TXT格式存放 ,
X45 S1-1 876 14.6 0 0 0 0 0 0 0
X45 S2-1 890.6 2.8 0.2 0 0 1 -999 -999 0
X45 S2-1-1 893.4 2.4 1 -999 0 1 -999 -999 0
取3 4 8 9 10 11列数据 放在记事本中?谢谢各位大虾。。
X45 S1-1 876 14.6 0 0 0 0 0 0 0
X45 S2-1 890.6 2.8 0.2 0 0 1 -999 -999 0
X45 S2-1-1 893.4 2.4 1 -999 0 1 -999 -999 0
取3 4 8 9 10 11列数据 放在记事本中?谢谢各位大虾。。
作者: dingpeng0405 发布时间: 2011-09-06
这个还用编程啊。直接复制粘贴就好了
作者: zoujing1000 发布时间: 2011-09-07
VB code
给你一段vba写入 txt 代码
Sub Macro10() Dim st As Worksheet Dim wk As Excel.Workbook Set wk = Excel.ActiveWorkbook For i = 1 To wk.Sheets.Count 'MsgBox wk.Sheets(i).Name If Trim(wk.Sheets(i).Name) = "QPM" Then Set st = wk.Sheets(i) End If Next i Dim strpath As String If Right(wk.Path, 1) = "\" Then strpath = wk.Path Else strpath = wk.Path & "\" End If MsgBox st.UsedRange.Columns.Count MsgBox st.UsedRange.Rows.Count For i = 1 To st.UsedRange.Columns.Count For j = 1 To st.UsedRange.Rows.Count If IsNumeric(st.Cells(j, i)) = True Then If j >= 17 Then str1 = str1 & Format(st.Cells(j, i), "####0.0000") & vbTab Else str1 = str1 & st.Cells(j, i) & vbTab End If Else str1 = str1 & st.Cells(j, i) & vbTab End If Next j str1 = Left(str1, Len(str1) - 1) str1 = str1 & vbCrLf Next i str1 = Left(str1, Len(str1) - 2) writefile命令 Dim fso As Object, f As Object Set fso = CreateObject("scripting.filesystemobject") Set f = fso.opentextfile(strpath & "LAT.txt", 2, True) '这里的8表示追加写入,如果是覆盖的话就用2 f.write str1 'f.writeline "xxx" '这个和print语句相似 f.Close MsgBox "success10" End Sub
给你一段vba写入 txt 代码
作者: yikeda 发布时间: 2011-09-07
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28