Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default I protect sheet - Macro will not run now

I have written a Macro that automatically hides rows on a sheet upon opening
the file. When I protect the sheet, I get a run-time error 1004 "Unable to
set the hidden property of the Range Class". QUESTION: How do I get this
macro to run and protect most of the cells on the sheet? Here is the code.

Sub Auto_open()
'
' Auto_open Macro
' Hides rows 8 through 28 on "Current" worksheet
'
' Keyboard Shortcut: Ctrl+h
'
Sheets("CURRENT").Select
Rows("8:28").Select
Selection.EntireRow.Hidden = True
Sheets("Cover").Select
End Sub
--
Marc
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default I protect sheet - Macro will not run now

WorkSheets("Current").unprotect "password"
and
WorkSheets("Current").protect "password"

"Marcus Analyst" wrote in message
...
I have written a Macro that automatically hides rows on a sheet upon
opening
the file. When I protect the sheet, I get a run-time error 1004 "Unable to
set the hidden property of the Range Class". QUESTION: How do I get this
macro to run and protect most of the cells on the sheet? Here is the code.

Sub Auto_open()
'
' Auto_open Macro
' Hides rows 8 through 28 on "Current" worksheet
'
' Keyboard Shortcut: Ctrl+h
'
Sheets("CURRENT").Select
Rows("8:28").Select
Selection.EntireRow.Hidden = True
Sheets("Cover").Select
End Sub
--
Marc



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default I protect sheet - Macro will not run now

Thanks! I'll give this a shot!
--
Marc


"C Brehm" wrote:

WorkSheets("Current").unprotect "password"
and
WorkSheets("Current").protect "password"

"Marcus Analyst" wrote in message
...
I have written a Macro that automatically hides rows on a sheet upon
opening
the file. When I protect the sheet, I get a run-time error 1004 "Unable to
set the hidden property of the Range Class". QUESTION: How do I get this
macro to run and protect most of the cells on the sheet? Here is the code.

Sub Auto_open()
'
' Auto_open Macro
' Hides rows 8 through 28 on "Current" worksheet
'
' Keyboard Shortcut: Ctrl+h
'
Sheets("CURRENT").Select
Rows("8:28").Select
Selection.EntireRow.Hidden = True
Sheets("Cover").Select
End Sub
--
Marc




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default I protect sheet - Macro will not run now

Sub Auto_open()
'
' Auto_open Macro
' Hides rows 8 through 28 on "Current" worksheet
'
' Keyboard Shortcut: Ctrl+h
'
Sheets("CURRENT").Select
ActiveSheet.Unprotect Password:="justme"
Rows("8:28").EntireRow.Hidden = True
ActiveSheet.Protect Password:="justme"
Sheets("Cover").Select
End Sub


Gord Dibben MS Excel MVP

On Mon, 7 Jan 2008 14:24:03 -0800, Marcus Analyst
wrote:

I have written a Macro that automatically hides rows on a sheet upon opening
the file. When I protect the sheet, I get a run-time error 1004 "Unable to
set the hidden property of the Range Class". QUESTION: How do I get this
macro to run and protect most of the cells on the sheet? Here is the code.

Sub Auto_open()
'
' Auto_open Macro
' Hides rows 8 through 28 on "Current" worksheet
'
' Keyboard Shortcut: Ctrl+h
'
Sheets("CURRENT").Select
Rows("8:28").Select
Selection.EntireRow.Hidden = True
Sheets("Cover").Select
End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default I protect sheet - Macro will not run now

Thanks Gord! I'll try this now!
--
Marc


"Gord Dibben" wrote:

Sub Auto_open()
'
' Auto_open Macro
' Hides rows 8 through 28 on "Current" worksheet
'
' Keyboard Shortcut: Ctrl+h
'
Sheets("CURRENT").Select
ActiveSheet.Unprotect Password:="justme"
Rows("8:28").EntireRow.Hidden = True
ActiveSheet.Protect Password:="justme"
Sheets("Cover").Select
End Sub


Gord Dibben MS Excel MVP

On Mon, 7 Jan 2008 14:24:03 -0800, Marcus Analyst
wrote:

I have written a Macro that automatically hides rows on a sheet upon opening
the file. When I protect the sheet, I get a run-time error 1004 "Unable to
set the hidden property of the Range Class". QUESTION: How do I get this
macro to run and protect most of the cells on the sheet? Here is the code.

Sub Auto_open()
'
' Auto_open Macro
' Hides rows 8 through 28 on "Current" worksheet
'
' Keyboard Shortcut: Ctrl+h
'
Sheets("CURRENT").Select
Rows("8:28").Select
Selection.EntireRow.Hidden = True
Sheets("Cover").Select
End Sub





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default I protect sheet - Macro will not run now

Thanks so much! This worked terrifically!
--
Marc


"Gord Dibben" wrote:

Sub Auto_open()
'
' Auto_open Macro
' Hides rows 8 through 28 on "Current" worksheet
'
' Keyboard Shortcut: Ctrl+h
'
Sheets("CURRENT").Select
ActiveSheet.Unprotect Password:="justme"
Rows("8:28").EntireRow.Hidden = True
ActiveSheet.Protect Password:="justme"
Sheets("Cover").Select
End Sub


Gord Dibben MS Excel MVP

On Mon, 7 Jan 2008 14:24:03 -0800, Marcus Analyst
wrote:

I have written a Macro that automatically hides rows on a sheet upon opening
the file. When I protect the sheet, I get a run-time error 1004 "Unable to
set the hidden property of the Range Class". QUESTION: How do I get this
macro to run and protect most of the cells on the sheet? Here is the code.

Sub Auto_open()
'
' Auto_open Macro
' Hides rows 8 through 28 on "Current" worksheet
'
' Keyboard Shortcut: Ctrl+h
'
Sheets("CURRENT").Select
Rows("8:28").Select
Selection.EntireRow.Hidden = True
Sheets("Cover").Select
End Sub



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default I protect sheet - Macro will not run now

Glad to hear it did the trick.

Gord

On Mon, 7 Jan 2008 15:44:03 -0800, Marcus Analyst
wrote:

Thanks so much! This worked terrifically!


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default I protect sheet - Macro will not run now

if you use this to protect it, you won't have to worry if the sheet is protected
or not when you run your code,

Worksheets("Sheet1").Protect UserInterfaceOnly:=True

--


Gary


"Marcus Analyst" wrote in message
...
I have written a Macro that automatically hides rows on a sheet upon opening
the file. When I protect the sheet, I get a run-time error 1004 "Unable to
set the hidden property of the Range Class". QUESTION: How do I get this
macro to run and protect most of the cells on the sheet? Here is the code.

Sub Auto_open()
'
' Auto_open Macro
' Hides rows 8 through 28 on "Current" worksheet
'
' Keyboard Shortcut: Ctrl+h
'
Sheets("CURRENT").Select
Rows("8:28").Select
Selection.EntireRow.Hidden = True
Sheets("Cover").Select
End Sub
--
Marc



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
Protect Sheet Macro jrob54245 Excel Worksheet Functions 2 November 6th 08 09:25 PM
Macro with protect sheet Pyrite Excel Discussion (Misc queries) 1 October 10th 08 05:03 PM
Protect sheet in macro traima Excel Worksheet Functions 3 March 9th 07 06:05 PM
Using macro to un/protect sheet Bonbon Excel Worksheet Functions 2 February 23rd 06 08:14 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 03:54 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"