+ Reply to Thread
Results 1 to 4 of 4

Run-time error '1004': Unable to set the Hidden property of the Range class

  1. #1
    Registered User
    Join Date
    03-30-2022
    Location
    Toronto
    MS-Off Ver
    Windows 10
    Posts
    5

    Run-time error '1004': Unable to set the Hidden property of the Range class

    Hi there-

    I'm new to this forum but hopefully someone can help me out.

    - I have this Excel Sheet with hidden cells (IF Conditions) that opens depending if you answer YES/NO.

    - I also have Grouped Cells that will expand or collapse if you click on the left side slider.

    - I need to protect both worksheets (which I did and only unlocked the cells where people are required to respond Yes/No or type in a particular cell.

    My issue:
    - Every time I save and then open the Excel file I get "Run-time error '1004' - Unable to set the Hidden property of the Range class"
    - Since I need to protect the worksheets none of the hidden cells (IF Conditions) will work and I can't collapse any of the Grouped Cells.

    I tried adding some VBA Code that I found but doesn't seem to work...

    Any help would be great!
    Attached Files Attached Files

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Run-time error '1004': Unable to set the Hidden property of the Range class

    Is the sheet protected at the time that the code to hide rows is executed? If the sheet is protected, you will not be able to hide/unhide rows. Your code will have to unprotect the sheet, hide the rows, then protect the sheet.

    I am unclear as to how saving and opening is related to this problem. There is no code in ThisWorkbook that runs when you open the file.

    Please describe the steps needed to reproduce the error.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    03-30-2022
    Location
    Toronto
    MS-Off Ver
    Windows 10
    Posts
    5

    Re: Run-time error '1004': Unable to set the Hidden property of the Range class

    Thanks Jeff for your reply.

    So basically this is what I'm doing:
    1. I unprotected the worksheet

    2. I created all of the IF Conditions that hide and unhide cells based upon the responses. (this is in VBA Project)

    3. I grouped certain rows so they can collapse or expand.

    4. I went to VBAProject and created a Module (I found it in this Forum) so that when I protect my worksheet the grouped rows will collapse and expand:
    Sub allowGroup()
    Dim mySheet As Worksheet
    Set mySheet = Application.ActiveSheet
    Dim myPW As String
    myPW = Application.InputBox("Type one Password to protect your worksheet:", "allowGroup", "", Type:=2)
    mySheet.Protect Password:=myPW, Userinterfaceonly:=True
    mySheet.EnableOutlining = True
    End Sub

    5. I ran the Sub/UserForm and added a pwd myPW and exited out of VBA Project.

    6. I can see that the worksheet is protected.

    7. The worksheet allows me to expand and collapse the protected grouped rows AND my IF Conditions open up the hidden rows.

    Now here is what's frustrating me...
    8. I close the Excel sheet.

    9. I open the Excel sheet.

    10. I try to expand one of the grouped rows and I get the following message: "You cannot use this command on a protected sheet. To use this commend, you must first unprotect the sheet...." Since many users will be using this worksheet, I was hoping to avoid them unprotecting the worksheet in order to see the rows since there's a lot of information.

    11. When I click one of the Yes/No boxes, I get the following message: "Run-time error '1004': Unable to set the Hidden property of the Range class"

    So basically are you saying that:
    a. There's no Coding that would allow me to group ad protect rows?

    b. Is my VBAProject need to be edits so my IF Conditions will work when I protect the worksheet?

    Thanks again!

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Run-time error '1004': Unable to set the Hidden property of the Range class

    Sorry I overlooked this thread for so long.

    The code you described in #4 is duplicated in four modules. Also it is not called from anywhere so I'm not sure how you intend to use it.

    Also I have another version of your file from another one of your threads that you posted the day after your last post above. It doesn't seem to have the problems you described here. Are you still trying to solve this?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] MergeCells & Run-time error '1004' - Unable to set the Hidden property of the Range class
    By jmdk11 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-04-2022, 05:40 PM
  2. Run time error 1004 - Unable to set the hidden property of the range class
    By excelconditional in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-16-2018, 12:09 PM
  3. Run-time error '1004': Unable to set the hidden property of the range class
    By lovekush in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-10-2017, 05:29 AM
  4. [SOLVED] Run-time error '1004' - Unable to set the Hidden property of the Range class
    By redoscar in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-04-2017, 09:34 AM
  5. [SOLVED] Run time error 1004: Unable to set hidden property of range class
    By SAVIOBLUEFOX in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-06-2013, 10:38 AM
  6. Help Please w/ Run-time error '1004' Unable to set the Hidden property of the Range Class
    By ExcelNewbie2534 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-18-2012, 07:38 PM
  7. Run-time error 1004: Unable to set the hidden property of the Range class.
    By seabee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-14-2011, 05:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1