+ Reply to Thread
Results 1 to 2 of 2

protected sheets - VBA error

  1. #1
    Registered User
    Join Date
    12-14-2021
    Location
    kuching
    MS-Off Ver
    home: Excel 365, working: Excel 2016
    Posts
    50

    protected sheets - VBA error

    hi, I need help.
    When I protect my worksheets VBA error notifications come out.
    All cell are Locked.
    Thank you vermu much.
    error 1004.jpg

    VBA:
    Sub HideRowCellEmpty()
    StartRow = 31
    LastRow = 510
    iCol = 21
    For i = StartRow To LastRow
    If Cells(i, iCol).Value <> "" Then
    Cells(i, iCol).EntireRow.Hidden = False
    Else
    Cells(i, iCol).EntireRow.Hidden = True
    End If
    Next i
    End Sub
    Last edited by habids; 01-30-2023 at 10:21 PM.

  2. #2
    Registered User
    Join Date
    12-14-2021
    Location
    kuching
    MS-Off Ver
    home: Excel 365, working: Excel 2016
    Posts
    50

    Re: protected sheets - VBA error

    oh I solved with this:

    Sub HideRowCellEmpty()
    Worksheets("Test1").Unprotect Password:="pass"
    StartRow = 31
    LastRow = 510
    iCol = 21
    For i = StartRow To LastRow
    If Cells(i, iCol).Value <> "" Then
    Cells(i, iCol).EntireRow.Hidden = False
    Else
    Cells(i, iCol).EntireRow.Hidden = True
    End If
    Next i
    Worksheets("Test1").Protect Password:="pass"
    End Sub

+ 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. Error 1004 when no sheets are protected
    By brucemc777 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-04-2018, 09:54 AM
  2. error code 1001: paste special Method range class failed on protected sheets
    By Ity007 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-02-2016, 09:15 PM
  3. getting error when userform transfers to protected sheets
    By zacr in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-31-2014, 07:25 AM
  4. Automatically Delete Unused Sheets in Protected Wkbk with Protected Sheets?
    By leaning in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-06-2010, 08:49 PM
  5. Protected sheets w/macros giving runtime error 1004
    By cedarhill in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-03-2009, 07:59 AM
  6. Replies: 1
    Last Post: 09-19-2006, 02:02 AM
  7. Protected sheets - change error message
    By moglione1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-12-2006, 12:55 PM

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