Solved

Prevent user to unhide rows

Posted on 2012-03-13
8
676 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 46

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 46

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
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 …

803 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