踩F8宏即可完美运行,但无法正常工作

时间:2018-11-08 09:47:30

标签: excel vba debugging

我在寻找答案,但是也许因为我不是程序员,所以我很难找到解决方案。这是我的代码。提前致谢。 我正在尝试仅选择我在其他文件(Users Office 365)中没有的号码,并在使用完这些号码后将其复制到其他文件(用户Office 365)中。

Sub Officetres()
'
' Officetres Macro
'
' Scelta rapida da tastiera: CTRL+MAIUSC+J
'

Columns("A:A").Select
Application.Run "PERSONAL.XLSB!MatriculaSeleccion"
Columns("E:E").Select
Application.Run "PERSONAL.XLSB!MatriculaSeleccion"
Columns("H:H").Select
Application.Run "PERSONAL.XLSB!MatriculaSeleccion"
Range("A1").Select
Workbooks.Open "C:\Users\User Office 365.xlsx"
Windows("User Office 365.xlsx").Activate
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy


Windows("Student.xls").Activate
       Selection.End(xlDown).Select
ActiveCell.Offset(1).Select
Selection.Insert Shift:=xlDown

 ActiveCell.Offset(0, 1).Range("A1").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Range("A1").Select
With Selection
    .HorizontalAlignment = xlGeneral
    .VerticalAlignment = xlBottom
    .WrapText = True
    .Orientation = 0
    .AddIndent = False
    .ShrinkToFit = False
    .ReadingOrder = xlContext
    .MergeCells = False
End With
ActiveCell.FormulaR1C1 = "z"
ActiveCell.Offset(0, -1).Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.FormulaR1C1 = "z"
ActiveCell.Select
Selection.Copy
Range(Selection, Selection.End(xlUp)).Select
ActiveSheet.Paste
Range("A1").Select
   Application.CutCopyMode = False
Application.CutCopyMode = False
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$J$2085"), , xlYes).Name 
= _
    "Tabella1"

Range("Tabella1").Sort Key1:=Range("B1"), Order1:=xlDescending, Header:= _
    xlYes

ActiveSheet.Range("Tabella1").RemoveDuplicates Columns:=1, Header:= _
    xlYes

ActiveSheet.Range("Tabella1").RemoveDuplicates Columns:=3, Header:= _
    xlYes
    Selection.ListObject.ListRows(1).Delete
ActiveCell.Offset(1, 0).Range("Tabella1[[#Headers],[SIS ID]]").Select
Range(Selection, Selection.End(xlDown)).Select
If WorksheetFunction.CountA(Range("A2:a2")) = 0 Then
    Windows("User Office 365.xlsx").Activate
   ActiveWorkbook.Save
ActiveWindow.Close

Else
     Selection.Copy

Windows("User Office 365.xlsx").Activate

ActiveCell.Offset(1, 0).Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.Close


ActiveCell.Offset(-1, 0).Range("Tabella1[#All]").Select
ActiveCell.Activate
Selection.Copy
End If

End Sub

Here a picture of the file student

0 个答案:

没有答案