Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VB - With protected sheet

Dear Guys,

i have a simple Marco that basically hides some rows and columns when i pick
the hide option froma drop down list.

The problem is i protected the sheet, (but not the drop down list of course)
and when i choose the hide option, nothing happens!

The code is written below

Any suggestion is appreciated..

Thanks!


Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Reset
With Application
.EnableEvents = False
If Not Application.Intersect(Me.Range("T75"), Target) Is Nothing Then
Me.Rows("76:92").Hidden = (UCase(Target.Value) = "HIDE")
End If
If Not Application.Intersect(Me.Range("t6"), Target) Is Nothing Then
Me.Rows("7").Hidden = (UCase(Target.Value) = "HIDE")
End If
.EnableEvents = True
End With
Exit Sub


Reset:
Application.EnableEvents = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default VB - With protected sheet

You are right, if it is protected, the code does not work. But the code
would not work anyhow as currently structured. Try this:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Reset
With Application
.EnableEvents = False
If Not Application.Intersect(Me.Range("T75"), Target) Is Nothing Then
Me.Rows("76:92").Hidden = (UCase(Target.Value) = "HIDE")
End If
If Not Application.Intersect(Me.Range("t6"), Target) Is Nothing Then
Me.Rows("7").Hidden = (UCase(Target.Value) = "HIDE")
End If
.EnableEvents = True
End With
Exit Sub


Reset:
Application.EnableEvents = True
End Sub

"Batshon" wrote:

Dear Guys,

i have a simple Marco that basically hides some rows and columns when i pick
the hide option froma drop down list.

The problem is i protected the sheet, (but not the drop down list of course)
and when i choose the hide option, nothing happens!

The code is written below

Any suggestion is appreciated..

Thanks!


Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Reset

With Application
.EnableEvents = False
If Not Application.Intersect(Me.Range("T75"), Target) Is Nothing Then
Me.Rows("76:92").Hidden = True
If Not Application.Intersect(Me.Range("t6"), Target) Is Nothing Then
Me.Rows("7").Hidden = True
End If
.EnableEvents = True
End With
Exit Sub
Reset:
Application.EnableEvents = True
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VB - With protected sheet

thanks for your reply man, but it is working perfectly fine in an unprotected
mode.
is there any trick that i can make the cade work under a protected mode?

Thanks!

"JLGWhiz" wrote:

You are right, if it is protected, the code does not work. But the code
would not work anyhow as currently structured. Try this:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Reset
With Application
.EnableEvents = False
If Not Application.Intersect(Me.Range("T75"), Target) Is Nothing Then
Me.Rows("76:92").Hidden = (UCase(Target.Value) = "HIDE")
End If
If Not Application.Intersect(Me.Range("t6"), Target) Is Nothing Then
Me.Rows("7").Hidden = (UCase(Target.Value) = "HIDE")
End If
.EnableEvents = True
End With
Exit Sub


Reset:
Application.EnableEvents = True
End Sub

"Batshon" wrote:

Dear Guys,

i have a simple Marco that basically hides some rows and columns when i pick
the hide option froma drop down list.

The problem is i protected the sheet, (but not the drop down list of course)
and when i choose the hide option, nothing happens!

The code is written below

Any suggestion is appreciated..

Thanks!


Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Reset

With Application
.EnableEvents = False
If Not Application.Intersect(Me.Range("T75"), Target) Is Nothing Then
Me.Rows("76:92").Hidden = True
If Not Application.Intersect(Me.Range("t6"), Target) Is Nothing Then
Me.Rows("7").Hidden = True
End If
.EnableEvents = True
End With
Exit Sub
Reset:
Application.EnableEvents = True
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default VB - With protected sheet


I might suggest that you have your code unprotect the sheet immediatley
before you hide the rows, then protect it again just before you return it to
the user.
"Batshon" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Reset
active sheet.unprotect password:="your password here"
....your code here
activesheet.protect password:="your password"
Exit Sub



thanks for your reply man, but it is working perfectly fine in an unprotected
mode.
is there any trick that i can make the cade work under a protected mode?

Thanks!

"JLGWhiz" wrote:

You are right, if it is protected, the code does not work. But the code
would not work anyhow as currently structured. Try this:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Reset
With Application
.EnableEvents = False
If Not Application.Intersect(Me.Range("T75"), Target) Is Nothing Then
Me.Rows("76:92").Hidden = (UCase(Target.Value) = "HIDE")
End If
If Not Application.Intersect(Me.Range("t6"), Target) Is Nothing Then
Me.Rows("7").Hidden = (UCase(Target.Value) = "HIDE")
End If
.EnableEvents = True
End With
Exit Sub


Reset:
Application.EnableEvents = True
End Sub

"Batshon" wrote:

Dear Guys,

i have a simple Marco that basically hides some rows and columns when i pick
the hide option froma drop down list.

The problem is i protected the sheet, (but not the drop down list of course)
and when i choose the hide option, nothing happens!

The code is written below

Any suggestion is appreciated..

Thanks!


Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Reset

With Application
.EnableEvents = False
If Not Application.Intersect(Me.Range("T75"), Target) Is Nothing Then
Me.Rows("76:92").Hidden = True
If Not Application.Intersect(Me.Range("t6"), Target) Is Nothing Then
Me.Rows("7").Hidden = True
End If
.EnableEvents = True
End With
Exit Sub
Reset:
Application.EnableEvents = True
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Protected Sheet DonB Excel Discussion (Misc queries) 2 June 5th 08 05:49 PM
Protected cells in Protected sheet Nenad_S[_2_] Excel Programming 0 February 5th 08 02:40 PM
Sheet Information - Is sheet protected? lbit Excel Discussion (Misc queries) 1 November 15th 07 08:06 PM
Protected sheet to unprotected sheet [email protected] Excel Worksheet Functions 2 October 26th 05 05:30 PM
excel - macro code to open a protected sheet, enter passowrd, and then protect sheet arunjoshi[_5_] Excel Programming 1 May 2nd 04 03:50 PM


All times are GMT +1. The time now is 02:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"