Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Hide all Sheets

Here is my code!
The last part of code that should hide all sheets do not work , the
first part for password is OK.

Where have I go wrong!
******************
Sub Auto_Close()
'
'
Dim Password 'This line of code is optional
Dim myCount 'This line of code is optional
Dim i 'This line of code is optional

myCount = Application.Sheets.Count

Sheets(1).Select 'This line of code selects the 1st sheet

For i = 1 To myCount
Password = "1234"
ActiveSheet.Protect Password, True, True, True


If i = myCount Then
End
End If
ActiveSheet.Next.Select

Next i

Dim myCount1 'This line of code is optional
Dim j 'This line of code is optional
myCount1 = Application.Sheets.Count
heets(1).Select 'This line of code selects the 1st sheet
For j = 1 To myCount1
ActiveSheet.Visible = xlSheetVeryHidden

If j = myCount1 Then
End
End If
ActiveSheet.Next.Select
Next j

ActiveWorkbook.Save

End Sub

************
Roba

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Hide all Sheets

One sheet must remain visible at all times. You can make a cover sheet and
hide all but that one.

Mike F
"Roba1" wrote in message
oups.com...
Here is my code!
The last part of code that should hide all sheets do not work , the
first part for password is OK.

Where have I go wrong!
******************
Sub Auto_Close()
'
'
Dim Password 'This line of code is optional
Dim myCount 'This line of code is optional
Dim i 'This line of code is optional

myCount = Application.Sheets.Count

Sheets(1).Select 'This line of code selects the 1st sheet

For i = 1 To myCount
Password = "1234"
ActiveSheet.Protect Password, True, True, True


If i = myCount Then
End
End If
ActiveSheet.Next.Select

Next i

Dim myCount1 'This line of code is optional
Dim j 'This line of code is optional
myCount1 = Application.Sheets.Count
heets(1).Select 'This line of code selects the 1st sheet
For j = 1 To myCount1
ActiveSheet.Visible = xlSheetVeryHidden

If j = myCount1 Then
End
End If
ActiveSheet.Next.Select
Next j

ActiveWorkbook.Save

End Sub

************
Roba



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Hide all Sheets

Hi Roba,

You can't hide all the sheets.Atleast one sheet must be visible

Thanks
Xcelion


"Roba1" wrote:

Here is my code!
The last part of code that should hide all sheets do not work , the
first part for password is OK.

Where have I go wrong!
******************
Sub Auto_Close()
'
'
Dim Password 'This line of code is optional
Dim myCount 'This line of code is optional
Dim i 'This line of code is optional

myCount = Application.Sheets.Count

Sheets(1).Select 'This line of code selects the 1st sheet

For i = 1 To myCount
Password = "1234"
ActiveSheet.Protect Password, True, True, True


If i = myCount Then
End
End If
ActiveSheet.Next.Select

Next i

Dim myCount1 'This line of code is optional
Dim j 'This line of code is optional
myCount1 = Application.Sheets.Count
heets(1).Select 'This line of code selects the 1st sheet
For j = 1 To myCount1
ActiveSheet.Visible = xlSheetVeryHidden

If j = myCount1 Then
End
End If
ActiveSheet.Next.Select
Next j

ActiveWorkbook.Save

End Sub

************
Roba


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Hide all Sheets

Also if make a change like that (left one sheet) it is stil not
working. If I use alone secound part of code it works, but together
with the first part it do not work. I have here two FOR functions. Do I
have to separate them with I dont know what???
Roba1

Sub Auto_Close()
'
' Makro1 Makro
' Makro ustvaril: ocvirk, dne 7.6.2006
'
Dim Password 'This line of code is optional
Dim myCount 'This line of code is optional
Dim i 'This line of code is optional
Dim wsSheet As Worksheet

myCount = Application.Sheets.Count

Sheets(1).Select 'This line of code selects the 1st sheet

For i = 1 To myCount
Password = "1234"
ActiveSheet.Protect Password, True, True, True


If i = myCount Then
End
End If
ActiveSheet.Next.Select

Next i

For Each wsSheet In Worksheets
wsSheet.Visible = wsSheet.Name = "List3"
Next wsSheet

ActiveWorkbook.Save

'
End Sub


Xcelion je napisal:
Hi Roba,

You can't hide all the sheets.Atleast one sheet must be visible

Thanks
Xcelion


"Roba1" wrote:

Here is my code!
The last part of code that should hide all sheets do not work , the
first part for password is OK.

Where have I go wrong!
******************
Sub Auto_Close()
'
'
Dim Password 'This line of code is optional
Dim myCount 'This line of code is optional
Dim i 'This line of code is optional

myCount = Application.Sheets.Count

Sheets(1).Select 'This line of code selects the 1st sheet

For i = 1 To myCount
Password = "1234"
ActiveSheet.Protect Password, True, True, True


If i = myCount Then
End
End If
ActiveSheet.Next.Select

Next i

Dim myCount1 'This line of code is optional
Dim j 'This line of code is optional
myCount1 = Application.Sheets.Count
heets(1).Select 'This line of code selects the 1st sheet
For j = 1 To myCount1
ActiveSheet.Visible = xlSheetVeryHidden

If j = myCount1 Then
End
End If
ActiveSheet.Next.Select
Next j

ActiveWorkbook.Save

End Sub

************
Roba



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Hide all Sheets

i FOUND SOLUTION!!
tHANKS ALL!
Roba1

Dim Password 'This line of code is optional
Dim myCount 'This line of code is optional
Dim i 'This line of code is optional

myCount = Application.Sheets.Count - 1

Sheets(1).Select 'This line of code selects the 1st sheet

For i = 1 To myCount
Password = "1234"
ActiveSheet.Protect Password, True, True, True


If i = myCount Then
End
End If
Call HideSheet
Next i

ActiveWorkbook.Save
'
End Sub

Sub HideSheet()
Dim wsSheet As Worksheet

For Each wsSheet In Worksheets
wsSheet.Visible = wsSheet.Name = "List3"
Next wsSheet


End Sub


Roba1 je napisal:
Also if make a change like that (left one sheet) it is stil not
working. If I use alone secound part of code it works, but together
with the first part it do not work. I have here two FOR functions. Do I
have to separate them with I dont know what???
Roba1

Sub Auto_Close()
'
' Makro1 Makro
' Makro ustvaril: ocvirk, dne 7.6.2006
'
Dim Password 'This line of code is optional
Dim myCount 'This line of code is optional
Dim i 'This line of code is optional
Dim wsSheet As Worksheet

myCount = Application.Sheets.Count

Sheets(1).Select 'This line of code selects the 1st sheet

For i = 1 To myCount
Password = "1234"
ActiveSheet.Protect Password, True, True, True


If i = myCount Then
End
End If
ActiveSheet.Next.Select

Next i

For Each wsSheet In Worksheets
wsSheet.Visible = wsSheet.Name = "List3"
Next wsSheet

ActiveWorkbook.Save

'
End Sub


Xcelion je napisal:
Hi Roba,

You can't hide all the sheets.Atleast one sheet must be visible

Thanks
Xcelion


"Roba1" wrote:

Here is my code!
The last part of code that should hide all sheets do not work , the
first part for password is OK.

Where have I go wrong!
******************
Sub Auto_Close()
'
'
Dim Password 'This line of code is optional
Dim myCount 'This line of code is optional
Dim i 'This line of code is optional

myCount = Application.Sheets.Count

Sheets(1).Select 'This line of code selects the 1st sheet

For i = 1 To myCount
Password = "1234"
ActiveSheet.Protect Password, True, True, True


If i = myCount Then
End
End If
ActiveSheet.Next.Select

Next i

Dim myCount1 'This line of code is optional
Dim j 'This line of code is optional
myCount1 = Application.Sheets.Count
heets(1).Select 'This line of code selects the 1st sheet
For j = 1 To myCount1
ActiveSheet.Visible = xlSheetVeryHidden

If j = myCount1 Then
End
End If
ActiveSheet.Next.Select
Next j

ActiveWorkbook.Save

End Sub

************
Roba



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
macro to hide sheets EricBB Excel Discussion (Misc queries) 5 August 10th 09 07:49 PM
Hide Sheets KrispyData Excel Discussion (Misc queries) 2 March 25th 09 06:42 PM
Can you hide Sheets? Abdul Excel Discussion (Misc queries) 10 November 30th 08 07:09 PM
Hide sheets Tia[_3_] Excel Worksheet Functions 3 July 7th 08 08:13 PM
Hide all sheets but selected sheets - an example [email protected] Excel Programming 1 April 7th 06 06:29 PM


All times are GMT +1. The time now is 05:13 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"