Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
192to196
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
192to196
192to196
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Run time error 1004

Run time error 1004
22.12.2002 15:50:52
Jeetesh Gurnani
Hi Friends,

I am working on Excel File and VBA. Can anyone tell me what's wrong with following command:

Private Sub optMonday_Click()
Sheet1.Unprotect
'Now here I want to enter some values.....and in the next line want to re-protect sheet....
Sheet1.Protect
End Sub

Tha above always displays an error as:

Method 'Unprotect' of object '_Worksheet' failed

similarly, Method 'Protect' of object '_Worksheet' failed 'when I try to Protect it......

Please let me know, how I can Protect and Unprotect the Sheet dynamically...

Thanx in advance.

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
Re: Run time error 1004
22.12.2002 15:58:39
PeterW
Hi Geetesh,

the reason for this error is your "Sheet1", it has to be "Sheets(1)"

regards
Peter

Re: Run time error 1004
22.12.2002 18:50:18
Nike
Hi,
watch out, if sheet1 isn`t positioned as the first sheet in
your folder, you might get into trouble, just to be on the
safe side you might want to try out
worksheets("Sheet1").unprotect
This way you make sure that only the sheet with the name
Sheet1 get`s unprotected no matter where it is positioned
This might be important in case you have moved your sheets
inside your Folder...

On the other hand you get an error if you rename the sheet
to SheetNumberOne. Then you would have to write
worksheets("SheetNumberOne").unprotect

Apart from that you might also have to supply a valid
password in case you used one to protect it in the first place...
Please have a look at the MS Help file for details on using the
pasword to unprotect a sheet...

Bye

Nike

Anzeige
Re: Run time error 1004
22.12.2002 19:01:09
PeterW
Hi Nike,

thanks for the additional information. I didn't realize that Sheet1 in English is the same as Tabelle1 in a German Excel.

best
Peter

220 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige