Public Sub GatherDataInSameWorkbook()
AppSettings ' On Error GoTo ErrHandler Dim StartTime, UsedTime As Variant
StartTime = VBA.Timer
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Dim wb As Workbook
Dim Sht As Worksheet
Dim Rng As Range
Dim OneSht As Worksheet
Dim SheetCount As Long
Const SHEET_NAME As String = "总表"
Const HEAD_ROW As Long = 1 '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Set wb = Application.ThisWorkbook '工作簿级别
Set Sht = wb.Worksheets(SHEET_NAME)
Sht.UsedRange.Offset(2).Clear For Each OneSht In wb.Worksheets
If OneSht.Name Like "*系统" Then
With OneSht
EndRow = .Cells.Find("*", .Cells(1, 1), xlValues, xlWhole, xlByRows, xlPrevious).Row
Set Rng = .Range("A3:Q" & EndRow)
Debug.Print .Name; " "; Rng.Address
EndRow = Sht.Cells.Find("*", Sht.Cells(1, 1), xlValues, xlWhole, xlByRows, xlPrevious).Row + 1
Rng.Copy Sht.Cells(EndRow, 1)
End With
End If
Next '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
UsedTime = VBA.Timer - StartTime
Debug.Print "UsedTime :" & Format(UsedTime, "#0.0000 Seconds")
'MsgBox "UsedTime :" & Format(UsedTime, "#0.0000 Seconds") ErrorExit:
Set wb = Nothing
Set Sht = Nothing
Set OneSht = Nothing
Set Rng = Nothing
AppSettings False
Exit Sub
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ErrHandler:
If Err.Number <> 0 Then
MsgBox Err.Description & "!", vbCritical, " QQ "
'Debug.Print Err.Description
Err.Clear
Resume ErrorExit
End If
End Sub
Public Sub AppSettings(Optional IsStart As Boolean = True)
Application.ScreenUpdating = IIf(IsStart, False, True)
Application.DisplayAlerts = IIf(IsStart, False, True)
Application.Calculation = IIf(IsStart, xlCalculationManual, xlCalculationAutomatic)
Application.StatusBar = IIf(IsStart, ">>>>>>>>Macro Is Running>>>>>>>>", False)
End Sub

  

20170906xlVBA_CopyDataAndFormatFromSheets的更多相关文章

随机推荐

  1. 展讯7731C_M Android6.0 充电指示灯实现(一)------关机充电实现【转】

    本文转载自:https://blog.csdn.net/m0_37870649/article/details/80566131 前言: 在手机充电中常常使用充电指示灯来观察手机充电状态,比如说将手机 ...

  2. 配置vim

    VundleVuldle是一个全自动的插件管理器,让我们通过维护插件列表的方式管理插件.它为安装.更新.删除插件提供了方便的命令.在安装Git的情况下(本文不赘述Git的安装),输入命令: git c ...

  3. 关于link标签的用法, 不声明rel=stylesheet则无效? 在ff中必须声明rel属性!

    void 无效的, 空的; invalid: 无效的, void 和 invalid 在表示无效的时候, 是一样的, 等同的 the treaty (条约) was declared invalid ...

  4. Depth-first search and Breadth-first search 深度优先搜索和广度优先搜索

    Depth-first search Depth-first search (DFS) is an algorithm for traversing or searching tree or grap ...

  5. IDEA旗舰版新建web项目

    即在一个Project下(MyEclipse中为工作空间)新建一个Module. 点击,在弹出框上打一个勾,如下图: 点Next,输入项目名,如下图: 点Finish, 右键WEB-INF,新建2个D ...

  6. IDEA 入门

    IDEA初步使用 IntelliJ IDEA 使用教程(2019图文版) -- 从入门到上瘾 IntelliJ IDEA 设置代码提示或自动补全的快捷键 (Alt+/) IntelliJ IDEA 配 ...

  7. pip运行错误

    错误: [root@centos64 numpy-1.13.1]# pip install numpy-1.13.1-cp27-cp27m-manylinux1_x86_64.whl Tracebac ...

  8. NLP related basic knowledge with deep learning methods

    NLP related basic knowledge with deep learning methods  2017-06-22   First things first >>> ...

  9. 【转】Windows Live Writer 代码插件改造

    源码和插件都在后面,如果不想看我神神叨叨的可以直接到文章后面下载 一 .找插件 在使用Windows Live Writer 经常要用到插入代码的功能,根据博客园中教程,分别使用了: WindowsL ...

  10. 【Java】【存储&作用域】

    [存储] 1. 寄存器.这是最快的保存群裕,因为它位于和其他所有保存方式不同的地方:处理器内部.然而,寄存器的数量有限,所以寄存器是根据需要由编译器分配.我们对此没有直接的控制权,也不可能在自己的程序 ...