Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ADK ADK is offline
external usenet poster
 
Posts: 89
Default unprotect next sheet

I have this code below which does not work with the next sheet. I think it
is ActiveSheet.Unprotect ("password") for the CompletionTable sheet. What is
wrong with the code not making it work past the first sheet?

Private Sub test_Click()
ActiveSheet.Unprotect ("password")
Dim lHiddenRws As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRws = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRws, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _
Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count + 1)
End With
ActiveSheet.Protect ("password")
Sheets("CompletionTable").Select
ActiveSheet.Unprotect ("password")
Dim lHiddenRwsb As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRwsb = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRwsb, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _
Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count + 1)
End With
ActiveSheet.Protect ("password")
Sheets("PDSR").Select
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default unprotect next sheet

Hi,

Does this help?

Sub stance()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
wSheet.Select

'Do your stuff here

Next wSheet
End Sub

Mike

"ADK" wrote:

I have this code below which does not work with the next sheet. I think it
is ActiveSheet.Unprotect ("password") for the CompletionTable sheet. What is
wrong with the code not making it work past the first sheet?

Private Sub test_Click()
ActiveSheet.Unprotect ("password")
Dim lHiddenRws As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRws = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRws, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _
Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count + 1)
End With
ActiveSheet.Protect ("password")
Sheets("CompletionTable").Select
ActiveSheet.Unprotect ("password")
Dim lHiddenRwsb As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRwsb = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRwsb, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _
Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count + 1)
End With
ActiveSheet.Protect ("password")
Sheets("PDSR").Select
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default unprotect next sheet

My guess would be that the password is not "password" or whatever string you
are really using.

--
Regards,
Tom Ogilvy


"ADK" wrote:

I have this code below which does not work with the next sheet. I think it
is ActiveSheet.Unprotect ("password") for the CompletionTable sheet. What is
wrong with the code not making it work past the first sheet?

Private Sub test_Click()
ActiveSheet.Unprotect ("password")
Dim lHiddenRws As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRws = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRws, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _
Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count + 1)
End With
ActiveSheet.Protect ("password")
Sheets("CompletionTable").Select
ActiveSheet.Unprotect ("password")
Dim lHiddenRwsb As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRwsb = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRwsb, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _
Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count + 1)
End With
ActiveSheet.Protect ("password")
Sheets("PDSR").Select
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
ADK ADK is offline
external usenet poster
 
Posts: 89
Default unprotect next sheet

the code goes to debug mode with an eror:

Run-time error '1004'

You cannot use this command on a protected sheet. To uprotect........


So the code is not unprotecting the second sheet before moving on with the
code


any ideas?


"Tom Ogilvy" wrote in message
...
My guess would be that the password is not "password" or whatever string
you
are really using.

--
Regards,
Tom Ogilvy


"ADK" wrote:

I have this code below which does not work with the next sheet. I think
it
is ActiveSheet.Unprotect ("password") for the CompletionTable sheet. What
is
wrong with the code not making it work past the first sheet?

Private Sub test_Click()
ActiveSheet.Unprotect ("password")
Dim lHiddenRws As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRws = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRws, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _
Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count +
1)
End With
ActiveSheet.Protect ("password")
Sheets("CompletionTable").Select
ActiveSheet.Unprotect ("password")
Dim lHiddenRwsb As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRwsb = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRwsb, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _
Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count +
1)
End With
ActiveSheet.Protect ("password")
Sheets("PDSR").Select
End Sub





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default unprotect next sheet

Try being more explicit
Activesheet.unprotect Password:="ABC"

this is not an asynchronous command, so it will be executed before moving on.

--
Regards,
Tom Ogilvy



"ADK" wrote:

the code goes to debug mode with an eror:

Run-time error '1004'

You cannot use this command on a protected sheet. To uprotect........


So the code is not unprotecting the second sheet before moving on with the
code


any ideas?


"Tom Ogilvy" wrote in message
...
My guess would be that the password is not "password" or whatever string
you
are really using.

--
Regards,
Tom Ogilvy


"ADK" wrote:

I have this code below which does not work with the next sheet. I think
it
is ActiveSheet.Unprotect ("password") for the CompletionTable sheet. What
is
wrong with the code not making it work past the first sheet?

Private Sub test_Click()
ActiveSheet.Unprotect ("password")
Dim lHiddenRws As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRws = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRws, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _
Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count +
1)
End With
ActiveSheet.Protect ("password")
Sheets("CompletionTable").Select
ActiveSheet.Unprotect ("password")
Dim lHiddenRwsb As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRwsb = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRwsb, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _
Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count +
1)
End With
ActiveSheet.Protect ("password")
Sheets("PDSR").Select
End Sub








  #6   Report Post  
Posted to microsoft.public.excel.programming
ADK ADK is offline
external usenet poster
 
Posts: 89
Default unprotect next sheet

still failed. stops at this line of code with that error message:

With Cells.SpecialCells(xlCellTypeVisible)


"Tom Ogilvy" wrote in message
...
Try being more explicit
Activesheet.unprotect Password:="ABC"

this is not an asynchronous command, so it will be executed before moving
on.

--
Regards,
Tom Ogilvy



"ADK" wrote:

the code goes to debug mode with an eror:

Run-time error '1004'

You cannot use this command on a protected sheet. To uprotect........


So the code is not unprotecting the second sheet before moving on with
the
code


any ideas?


"Tom Ogilvy" wrote in message
...
My guess would be that the password is not "password" or whatever
string
you
are really using.

--
Regards,
Tom Ogilvy


"ADK" wrote:

I have this code below which does not work with the next sheet. I
think
it
is ActiveSheet.Unprotect ("password") for the CompletionTable sheet.
What
is
wrong with the code not making it work past the first sheet?

Private Sub test_Click()
ActiveSheet.Unprotect ("password")
Dim lHiddenRws As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRws = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRws, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _

Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count +
1)
End With
ActiveSheet.Protect ("password")
Sheets("CompletionTable").Select
ActiveSheet.Unprotect ("password")
Dim lHiddenRwsb As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRwsb = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRwsb, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _

Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count +
1)
End With
ActiveSheet.Protect ("password")
Sheets("PDSR").Select
End Sub








  #7   Report Post  
Posted to microsoft.public.excel.programming
ADK ADK is offline
external usenet poster
 
Posts: 89
Default unprotect next sheet

I did a test with the following code and this one worked (both sheets
unprotected before test and after test both sheets were protected)....so
that tells me something other than the protect/uprotect portion is failing.

any ideas?


Private Sub TestMeNow_Click()
ActiveSheet.Unprotect ("123")
ActiveSheet.Protect ("123")
Sheets("CompletionTable").Select
ActiveSheet.Unprotect ("123")
ActiveSheet.Protect ("123")
Sheets("PDSR").Select
End Sub


"ADK" wrote in message
...
still failed. stops at this line of code with that error message:

With Cells.SpecialCells(xlCellTypeVisible)


"Tom Ogilvy" wrote in message
...
Try being more explicit
Activesheet.unprotect Password:="ABC"

this is not an asynchronous command, so it will be executed before moving
on.

--
Regards,
Tom Ogilvy



"ADK" wrote:

the code goes to debug mode with an eror:

Run-time error '1004'

You cannot use this command on a protected sheet. To uprotect........


So the code is not unprotecting the second sheet before moving on with
the
code


any ideas?


"Tom Ogilvy" wrote in message
...
My guess would be that the password is not "password" or whatever
string
you
are really using.

--
Regards,
Tom Ogilvy


"ADK" wrote:

I have this code below which does not work with the next sheet. I
think
it
is ActiveSheet.Unprotect ("password") for the CompletionTable sheet.
What
is
wrong with the code not making it work past the first sheet?

Private Sub test_Click()
ActiveSheet.Unprotect ("password")
Dim lHiddenRws As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRws = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRws, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _

Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count +
1)
End With
ActiveSheet.Protect ("password")
Sheets("CompletionTable").Select
ActiveSheet.Unprotect ("password")
Dim lHiddenRwsb As Long
With Cells.SpecialCells(xlCellTypeVisible)
lHiddenRwsb = .Areas(1).Rows.Count + 1
.Areas(1)(lHiddenRwsb, 1).EntireRow.Hidden = False
Range("A1").CurrentRegion.Rows(Range("A1") _
.CurrentRegion.Rows.Count).Copy Destination:= _

Range("A1").CurrentRegion.Rows(Range("A1").Current Region.Rows.Count +
1)
End With
ActiveSheet.Protect ("password")
Sheets("PDSR").Select
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
Unprotect sheet command - How do I do this? TKM Excel Worksheet Functions 7 April 2nd 23 08:58 PM
protect unprotect sheet vba ian bartlett Excel Programming 3 June 14th 07 04:15 AM
how to Unprotect sheet mangesh Excel Discussion (Misc queries) 1 July 24th 06 10:34 PM
Unprotect sheet when printing bbc1 Excel Discussion (Misc queries) 2 August 31st 05 01:41 AM
unprotect sheet in code and make sheet visible peach255 Excel Programming 1 August 1st 03 03:28 AM


All times are GMT +1. The time now is 03:00 AM.

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

About Us

"It's about Microsoft Excel"