zoukankan      html  css  js  c++  java
  • 将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
  • 相关阅读:
    BZOJ3156 防御准备
    BZOJ1257 余数之和
    BZOJ1879 Bill的挑战
    BZOJ1811 mea
    phpcms列表页内容如何替换?
    如何解决wamp中数据库读取数据是???的情况?
    如何用phpcms将静态网页生成动态网页?
    简单介绍phpcms以及phpcms如何安装?
    cms基本概念(dedecms,phpcms)
    用php+mysql+ajax实现淘宝客服或阿里旺旺聊天功能 之 后台页面
  • 原文地址:https://www.cnblogs.com/hao-1234-1234/p/10530027.html
Copyright © 2011-2022 走看看