Solved

Prevent user to unhide rows

Posted on 2012-03-13
8
644 Views
Last Modified: 2012-03-14
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
Comment
Question by:hkgal
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 19

Assisted Solution

by:Bardobrave
Bardobrave earned 100 total points
ID: 37714544
Have you tried blocking the worksheet?
0
 

Author Comment

by:hkgal
ID: 37714566
I just want to prevent then unhide and with other function normal, also users can still unhide other rows except that programmed ones...
0
 
LVL 19

Expert Comment

by:Bardobrave
ID: 37714651
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
 
LVL 45

Expert Comment

by:Martin Liss
ID: 37715267
You could put the rows in a different sheet and then hide/protect the sheet.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:hkgal
ID: 37715283
So no ways to hide the rows at the same time set things to prevent unhide?? in same place n worksheet?
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 37715350
I don't believe there is.
0
 
LVL 19

Expert Comment

by:Bardobrave
ID: 37715640
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
 
LVL 45

Accepted Solution

by:
aikimark earned 400 total points
ID: 37718161
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now