zoukankan      html  css  js  c++  java
  • EXCEL VBA中写了个宏把本EXCEL中的表数据批量导出为csv格式的文件

    Sub csv()
        Dim Fs, myFile As Object
        Dim myfileline As String 'txtfile的行数据
        Dim sht As Worksheet
       
        For Each sht In ThisWorkbook.Sheets
            ns = sht.Cells(1, 8)
            Set Fs = CreateObject("Scripting.FileSystemObject")   '建立filesytemobject
            Set myFile = Fs.createtextfile(ActiveWorkbook.Path + "csv" + ns + ".csv") '通过filesystemobject新建一个和xls文件同名的txt文件
            For i = 2 To 1000
                ra = sht.Cells(i, 3)
                If ra = "" Then Exit For
                rb = ""
                For j = 3 To 1000
                    ca = sht.Cells(2, j)
                    If ca = "" Then Exit For
                    If rb = "" Then
                        rb = sht.Cells(i, j).Value
                    Else
                        rb = rb & "," & sht.Cells(i, j).Value
                    End If
                Next j
                myFile.writeline (rb)
            Next i
            Set myFile = Nothing
            Set Fs = Nothing                   '关闭文件和filesystemobject对象
        Next
    End Sub

  • 相关阅读:
    mysql 查看存储过程 并导出
    mysql 添加记录或者删除记录
    mysql 修改表的字段
    搭建docker私有仓库
    安装gitlab并配置邮箱
    Mac 安装MySQL-python
    android studio 调试安装
    给定日期求星期几
    数字三角形
    程序设计实训-课程表管理系统项目中遇到的问题
  • 原文地址:https://www.cnblogs.com/swtool/p/4541561.html
Copyright © 2011-2022 走看看