我正在运行这个宏:
Sub Check()
ActiveSheet.EnableCalculation = False
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
If Sheets(1).Range("A1").Value = "Enter Data" Then
Sheets(2).Activate
Else
If Sheets(1).Range("H10").Value <> "" And Sheets(1).Range("I10").Value <> "" And Sheets(1).Range("J10").Value <> "" Then
Dim lastRow As Long
Dim sht1 As Worksheet
Dim sht2 As Worksheet
Set sht1 = Sheets(2)
If sht1.Range("A1").Value <> "" Then
'insert column b formula
lastRow = sht1.Range("A" & Rows.Count).End(xlUp).Row
sht1.Range("B2").Formula = "=MID(A2, 1, 12)"
sht1.Range("B2").AutoFill Destination:=sht1.Range("B2:B" & lastRow)
'insert column c formula
sht1.Range("C2").Formula = "=--LEFT(B2,4)"
sht1.Range("C2").AutoFill Destination:=sht1.Range("C2:C" & lastRow)
'insert column d formula
sht1.Range("D2").Formula = "=--RIGHT(MID(A2, 14, 7),LEN(MID(A2, 14, 7))-FIND(LEFT(SUBSTITUTE(MID(A2, 14, 7)&"" "",""0"",""""),1),MID(A2, 14, 7)&"" "")+1)"
sht1.Range("D2").AutoFill Destination:=sht1.Range("D2:D" & lastRow)
'insert column E formula
sht1.Range("E2").Formula = "=DATE(""20""&MID(B2,9,2),MID(B2,7,2),MID(B2,5,2))"
sht1.Range("E2").AutoFill Destination:=sht1.Range("E2:E" & lastRow)
'insert column F formula
sht1.Range("F2").Formula = "=IF(E2<>"""",WEEKNUM(E2,21),"""")"
sht1.Range("F2").AutoFill Destination:=sht1.Range("F2:F" & lastRow)
'insert column G formula
sht1.Range("G2").Formula = "=SUBSTITUTE(TRIM(MID(A2, FIND(""-"", A2, FIND(""-"", A2)+9)+9,256)),"" "","" / "")"
sht1.Range("G2").AutoFill Destination:=sht1.Range("G2:G" & lastRow)
Else
MsgBox "Please First Copy and Paste Estimated Receivings."
End If
Set sht2 = Sheets(1)
With sht2
If Range("H10").Value <> "" Then
lastRow = .Cells(.Rows.Count, 10).End(xlUp).Row
.Range("K10").FormulaArray = "=IFERROR(INDEX(Data!$G:$G,MATCH(1,(Home!$H10=Data!$C:$C)*(Home!$I10=Data!$D:$D)*(IF(Home!$J10<55,Home!$J10,WEEKNUM(Home!$J10,21))=Data!$F:$F),0)),"""")"
If lastRow <> 10 Then
.Range("K10").AutoFill ActiveSheet.Range("K10:K" & lastRow)
End If
.Range("M10").FormulaArray = "=IFERROR(INDEX(Data!$B:$B,MATCH(1,(Home!$H10=Data!$C:$C)*(Home!$I10=Data!$D:$D)*(IF(Home!$J10<55,Home!$J10,WEEKNUM(Home!$J10,21))=Data!$F:$F),0)),""No Po Found"")"
If lastRow <> 10 Then
.Range("M10").AutoFill ActiveSheet.Range("M10:M" & lastRow)
End If
.Range("L10").FormulaArray = "=IFERROR(INDEX(Data!$F:$F,MATCH(1,(Home!$H10=Data!$C:$C)*(Home!$I10=Data!$D:$D)*(IF(Home!$J10<55,Home!$J10,WEEKNUM(Home!$J10,21))=Data!$F:$F),0)),"""")"
If lastRow <> 10 Then
.Range("L10").AutoFill ActiveSheet.Range("L10:L" & lastRow)
End If
Else
MsgBox "Please enter some data."
End If
End With
Else
MsgBox "At Least One Order Must Be Checked."
End If
End If
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = True
ActiveSheet.EnableCalculation = True
End Sub
出于某种原因,当代码运行完毕后,我的Excel工作表会显示三条隔离的行:
为什么会这样,我该如何删除它们?我感谢任何帮助。感谢
答案 0 :(得分:3)
我认为你应该删除
ActiveSheet.DisplayPageBreaks = True