怎么用vba把vba代码复制粘贴
发布网友
发布时间:2022-04-23 00:53
我来回答
共4个回答
热心网友
时间:2023-07-10 14:23
试试下面的代码:
Sub Macro1()
Dim MyPath$, MyName$, sh As Worksheet, m&, w As WorksheetFunction, wb As Workbook
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set w = WorksheetFunction
MyPath = ThisWorkbook.Path & "\采集多数据"
MyName = Dir(MyPath & "*.xls*")
[a1].CurrentRegion.Offset(1).ClearContents
Do While MyName <> ""
With GetObject(MyPath & MyName)
With .Sheets(1)
If w.CountA(.UsedRange.Offset(1)) Then
m = m + 1
If m = 1 Then
Set wb = Workbooks.Add(xlWBATWorksheet)
Set sh = wb.ActiveSheet
.[a1].CurrentRegion.Copy sh.[a1]
Else
.[a1].CurrentRegion.Offset(1).Copy sh.[a65536].End(xlUp).Offset(1)
End If
End If
End With
.Close False
End With
MyName = Dir
Loop
wb.SaveAs Filename:=ThisWorkbook.Path & "\采集多数据20130422.xls", FileFormat:=xlExcel8
wb.Close
Application.ScreenUpdating = True
MsgBox "ok"
End Sub
热心网友
时间:2023-07-10 14:23
调用模块吧
热心网友
时间:2023-07-10 14:23
你想复制哪里的代码?粘贴到什么地方?
热心网友
时间:2023-07-10 14:24
这个还真没有想到过