[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 852
  • Last Modified:

Prevent user to unhide rows

I got a code and works well on hide/unhide info base on column G values:

Sub HideData()
 Dim cel As Range
 
 For Each cel In Columns("G")
  If LCase(Trim(cel.Text)) = "NIL" Then

   Rows(cel.Row).EntireRow.Hidden = True

  End If
 Next cel
   
End Sub



Sub SHOWData()
 Dim cel As Range
 For Each cel In Columns("G")
  If LCase(Trim(cel.Text)) = "NIL" Then
   Rows(cel.Row).EntireRow.Hidden = False

  End If
 Next cel
End Sub


However, I want to protect and prevent the users to unhide the row information when it is hidden. Any method?

Help....thanks!
0
hkgal
Asked:
hkgal
  • 3
  • 2
  • 2
  • +1
2 Solutions
 
BardobraveCommented:
Have you tried blocking the worksheet?
0
 
hkgalAuthor Commented:
I just want to prevent then unhide and with other function normal, also users can still unhide other rows except that programmed ones...
0
 
BardobraveCommented:
Well... and what about erasing those rows from the sheet? If users shouldn't be able to see them in any manner what's the point of having them there?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Martin LissRetired ProgrammerCommented:
You could put the rows in a different sheet and then hide/protect the sheet.
0
 
hkgalAuthor Commented:
So no ways to hide the rows at the same time set things to prevent unhide?? in same place n worksheet?
0
 
Martin LissRetired ProgrammerCommented:
I don't believe there is.
0
 
BardobraveCommented:
I don't know any way to directly block a cell or a row/column from show/hide.

Maybe by rendering them readonly? Have you tried it?
0
 
aikimarkCommented:
You can add code to either the worksheet's SelectionChange() event or the workbook's SheetSelectionChange() event.  If the selection is one or more rows or all the cells, then you can change the selection programmatically.  The row(s) must be selected before they can be unhidden.

You should also make the font and interior color of the hidden cells such that it will be very difficult to read even if the row is unhidden.

Worksheet-level example:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Columns.Count = Target.Worksheet.Columns.Count Then
        Target.Cells(1, 1).Select
    End If
End Sub

Open in new window

0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now