admin 管理员组文章数量: 887021
VBA
Private Declare PtrSafe Function timeGetTime Lib "winmm.dll" () As Long
'封装延时函数
Sub delay(T As Long)
Dim time1 As Long
time1 = timeGetTime
Do
DoEvents
Loop While timeGetTime - time1 < T
End Sub
Sub 宏1()
Dim i As Long, row_book As Long, column_book As Long
'遍历所有工作表(sheet)
For i = 1 To ActiveWorkbook.Worksheets.Count
'下面这句,亦可以用ActiveWorkbook.Worksheets(i).Activate 进行替代,代表激活此工作表
ActiveWorkbook.Worksheets(i).Select
'获取此激活的工作表的行和列
row_book = ActiveSheet.UsedRange.Rows.Count
column_book = ActiveSheet.UsedRange.Columns.Count
'选中所有数据,复制并粘贴为数值
Range("A1:" & Cells(row_book, column_book).Address).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'延迟2s 这里存粹是为了测试,看他有没有异常,实际运行中,上面的时间封装,和这个delay就可以不用了~
delay (2000)
Debug.Print (ActiveWorkbook.Worksheets(i).Name)
Next
End Sub
截图如下:
本文标签: VBA
版权声明:本文标题:VBA 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1687272095h83598.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论