• 将excel按照某一列拆分成多个文件(方案整理)


    1解决方案:将excel按照某一列拆分成多个文件

    百度得:https://blog.csdn.net/ntotl/article/details/79141314

    2遇到问题:解决vbe6ext.olb不能被加载 内存溢出 问题

    百度得:http://www.udaxia.com/wtjd/13635.html

    3问题原因:VBA文件位置不同

    有的是:C:Program Files (x86)Common Filesmicrosoft sharedVBA

    有的是:C:Program Files Common Filesmicrosoft sharedVBA

    而我两个位置都有VBA文件。所以我先把两个地方的VBA文件复制一份(怕搞错无法恢复),然后把两个地方的VBA6、VBA7.1 都试了一篇,最后成功了。

    4VB核心代码:

    Sub 保留表头拆分数据为若干新工作簿()
     Dim arr, d As Object, k, t, i&, lc%, rng As Range, c%
     c = Application.InputBox("请输入拆分列号", , 4, , , , , 1)
     If c = 0 Then Exit Sub
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    arr = [a1].CurrentRegion
    lc = UBound(arr, 2)
    Set rng = [a1].Resize(, lc)
     Set d = CreateObject("scripting.dictionary")
    For i = 2 To UBound(arr)
    If Not d.Exists(arr(i, c)) Then
    Set d(arr(i, c)) = Cells(i, 1).Resize(1, lc)
     Else
     Set d(arr(i, c)) = Union(d(arr(i, c)), Cells(i, 1).Resize(1, lc))
    End If
     Next
    k = d.Keys
     t = d.Items
    For i = 0 To d.Count - 1
    With Workbooks.Add(xlWBATWorksheet)
    rng.Copy .Sheets(1).[a1]
     t(i).Copy .Sheets(1).[a2]
     .SaveAs Filename:=ThisWorkbook.Path & "" & k(i) & ".xls"
     .Close
     End With
     Next
     Application.DisplayAlerts = True
     Application.ScreenUpdating = True
     MsgBox "完毕"
    End Sub
    View Code
  • 相关阅读:
    iOS 检测版本更新(02)
    iOS开发之检查更新
    Core Location :⽤用于地理定位
    TCP与UDP区别
    iOS设计模式之观察者模式
    联系人案例
    ksoap调用webservice
    Android获取内置sdcard跟外置sdcard路径
    百度sdk定位不成功,关闭定位
    PinnedHeaderListView实现删除
  • 原文地址:https://www.cnblogs.com/hao-1234-1234/p/10530027.html
Copyright © 2020-2023  润新知