我是脚本新手,我正在尝试改进现有的宏。我录制了一个宏以删除重复项并将其添加到调用其他一些函数的 Main 函数中,但是当我添加我录制的宏时出现此错误:
Run-time error '1004': Unable to set the hidden property of the range class
代码看起来像
Private Sub Worksheet_Change(ByVal Target As Range)
Dim changed As Range
Set changed = Intersect(Target, Range("J15"))
If Not changed Is Nothing Then
Range("A48:A136").EntireRow.Hidden = True
Select Case Target.Value
Case "Agriculture"
Range("A48:A96").EntireRow.Hidden = False
Case "Commercial"
Range("A97:A136").EntireRow.Hidden = False
Case "MDP"
Range("A48:A61").EntireRow.Hidden = False
End Select
Range("J15").Select
End If
End Sub