EXCEL VB 代码,高手来帮忙,谢谢!
发布网友
发布时间:2023-01-02 08:18
我来回答
共2个回答
热心网友
时间:2023-10-09 08:42
Sub mysub()
Dim ShApp As Object, mysheet As Object
Dim TF As Boolean, i As Integer, r As Long
Dim aTable As Object, n As Integer
Dim str As String
On Error Resume Next
n = 0
WithApplication.FileDialog(msoFileDialogFilePicker)
.Title = "请选定要处理的excel文档"
.Filters.Add "excel文档", "*.xls" '暂定扩展名为xls的excel文档
.AllowMultiSelect = True
If .Show <> -1 Then Exit Sub
Set ShApp = GetObject(, "Excel.Application")
If Err <> 0 Then
TF = True
Set ShApp = CreateObject("Excel.Application")
End If
Application.ScreenUpdating = False
For i = 1 To .SelectedItems.Count
Set mysheet = ShApp.Workbooks.Open(.SelectedItems(i))
With mysheet.Sheets(1) '
.Range(.Cells(2, 1),.Cells(.UsedRange.Rows.Count, .UsedRange.Columns.Count)).Copy[a65536].End(xlUp).Offset(1)
End With
n = n + 1
mysheet.Close False
Next i
End With
If TF = True Then ShApp.Quit
Set ShApp = Nothing
MsgBox "提取完毕!共提取了" & n & "个excel文档。"
Application.ScreenUpdating = True
End Sub
追问编译错误:无效或不合格的引用
追答在第8行的with 与 Application之间加一个空格。
热心网友
时间:2023-10-09 08:43
给vfdgvfsnhgnbngfhg孤鸿寡鹄工行办公会还敢不敢还不够和部分干部好吧公司部丹甫股份