我創建了一個腳本,在行的「 - 」行中隱藏了活動工作表中的行。我想將其應用於其他工作表(即Sheet-ABC,Sheet-DEF)。我嘗試使用數組,但不成功。Excel VBA,更新特定工作表,不僅僅是活動工作表
任何幫助表示讚賞。
Sub hideRows()
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False
Dim cell, cell2 As Range, hRws As Range
Set Rng = Sheet15.Range("A52:L359")
Rng.EntireRow.Hidden = False
For Each cell In Range("A52:L359").SpecialCells(xlBlanks)
If cell = "-" And cell.Offset(-1, 0) = "-" Then
If hRws Is Nothing Then
Set hRws = Range(cell, cell.Offset(1, 0))
Else
Set hRws = Union(hRws, Range(cell, cell.Offset(1, 0)))
End If
End If
Next
If Not hRws Is Nothing Then hRws.EntireRow.Hidden = True
Application.Calculation = xlCalculationAutomatic
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
嗯 - 如果你是通過空白單元格循環,多少都會有'一個值「 - 」'? – YowE3K