gpt4 book ai didi

vba - Excel - 运行时错误 '1004' : Unable to set the hidden property of the range class

转载 作者:行者123 更新时间:2023-12-03 14:05:30 28 4
gpt4 key购买 nike

我是脚本新手,我正在尝试改进现有的宏。我录制了一个宏以删除重复项并将其添加到调用其他一些函数的 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

最佳答案

一些可能的答案:

  • 您在所选单元格之一中有评论
  • 您有一些绘制的对象不使用文本调整大小
  • 您的工作表 protected

  • 当您在事件处理程序的第一行设置断点,然后按 F8 单步执行宏时,我假设它在该行崩溃:
    Range("A48:A136").EntireRow.Hidden = True

    关于vba - Excel - 运行时错误 '1004' : Unable to set the hidden property of the range class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13967033/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com