Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Prevent user to unhide rows

Posted on 2012-03-13
8
Medium Priority
?
809 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 400 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 49

Expert Comment

by:Martin Liss
ID: 37715267
You could put the rows in a different sheet and then hide/protect the sheet.
0
 

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 49

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 46

Accepted Solution

by:
aikimark earned 1600 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

879 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