我有一个工作表,其中第 2 行被隐藏。一个宏粘贴到这一行。每当我运行这个宏时,隐藏的行就会重新出现。
有没有办法防止该行再次出现?
这是我的代码,它仍然没有隐藏第 2 行
子更新2029()
Dim LSearchRow As Integer
Dim LCopyToRow As Integer
Dim LSearchValue As String
On Error GoTo Err_Execute
Application.ScreenUpdating = False
LSearchValue = InputBox("Please enter a serial number to search for.", "Enter value")
'Start search in row 5
LSearchRow = 5
'Start copying data to row 2 in "Master" (row counter variable)
LCopyToRow = 2
While Len(Range("A" & CStr(LSearchRow)).Value) > 0
'If value in column A = LSearchValue, copy entire row to "Master"
If Range("A" & CStr(LSearchRow)).Value = LSearchValue Then
'Select row in "Master" to copy
Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select
Selection.Copy
'Paste row into "Master" in row 2
Sheets("Master").Select
Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select
ActiveSheet.PasteSpecial
End If
LSearchRow = LSearchRow + 1
Wend
'Position on cell A3
Application.CutCopyMode = False
Range("A3").Select
MsgBox "All matching data has been copied to 2029."
Exit Sub
Err_Execute: MsgBox "发生错误。" Sheets("Master").Rows("2:2").EntireRowHidden = True ApplicationScreenUpdating = True
End Sub