Error 1004 - 'select method of worksheet class failed'

matthewh

New Member
Joined
Mar 13, 2002
Messages
34
Can anyone tell me why this code produces the error message above?

Sheets("Data").Select
Rows("2:2").Select
Selection.copy
Sheets("Hist").Unprotect

---this row causes problems -----
If Worksheets("Hist").Visible = True Then Sheets("Hist").Visible = True
---------------------------------
Sheets("Hist").Select
Range("A1").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Save
Sheets("Hist").Visible = False

That part of it I recorded cos I,ve started having problems with it, and it worked ok twicw and now I have problems with it again. This is the only thing stopping a nice app from working!

Thanks
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
does : -

If Worksheets("Hist").Visible = False Then Sheets("Hist").Visible = True
Sheets("Hist").Select

work OK? :)
 
Upvote 0
It used to... about an hour ago. Then stopped and I get the 1004 now. I don't get it - I recorded that bit!
 
Upvote 0
Doh! I realised the mistake as I hit the Submit button! Ok - so that bit's ok, now I get the 1004 on the last bit -

Sheets("Hist").Visible = True

but it says - Unable to set the Visible property on the Worksheet class.
Am I missing something here?
This message was edited by matthewh on 2002-05-29 05:46
 
Upvote 0
It unprotects it a couple of lines above that, then re-protects it. It's a history of some transactions that I can't have people changing.
 
Upvote 0
You're unprotecting your worksheet there, but is your actual workbook protected, as this can prevent your sheets from being hidden and unhidden?
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top