Run Time Error 1004 - Select Method of Worksheet Class Failed

AllanF

New Member
Joined
Mar 9, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I need some help please. This workbook has worked really well but recently (today) started giving the error when going to print the sheet, can you help.

Allan.
 

Attachments

  • Excel Error 1.PNG
    Excel Error 1.PNG
    36.7 KB · Views: 12
  • Excel Error 2.PNG
    Excel Error 2.PNG
    61.1 KB · Views: 12

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi @AllanF, Welcome to the MrExcel forum. Please accept my warmest greetings and sincere hope that all is well.

It seems that the sheet you are trying to select ("Leave Blank") is hidden. Before starting the process you must display the sheet, for example, add the following line to your macro:
VBA Code:
  Sheets("Leave Blank").Visible = xlSheetVisible
  Sheets("Leave Blank").Select

More improvements could be made to your macro, but it's hard to review from an image.
Note Code Tag:
In future please use code tags when posting code How to Post Your VBA Code it makes your code easier to read & copy, thereby increasing you chances of getting help.

Note XL2BB:
For the future, it would help greatly if you could give us the sample data in a form that we can copy to test with, rather that a picture.
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in
Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.

-----
Let me know the result and I'll get back to you as soon as I can.
Sincerely
Dante Amor
----- --
 
Upvote 0
Hi AllanF,

avoid using "Select" it slows down the code and is useless
If you have this message, it means that the sheet in question is invisible or does not exist

the first 4 lines, can be one
VBA Code:
ActiveSheet.Range("B6:K42").Copy Destination:=Sheets("Leave Blank").Range("A1")

Edit : hi DanteAmor
 
Upvote 0
Hi @AllanF, Welcome to the MrExcel forum. Please accept my warmest greetings and sincere hope that all is well.

It seems that the sheet you are trying to select ("Leave Blank") is hidden. Before starting the process you must display the sheet, for example, add the following line to your macro:
VBA Code:
  Sheets("Leave Blank").Visible = xlSheetVisible
  Sheets("Leave Blank").Select

More improvements could be made to your macro, but it's hard to review from an image.
Note Code Tag:
In future please use code tags when posting code How to Post Your VBA Code it makes your code easier to read & copy, thereby increasing you chances of getting help.

Note XL2BB:
For the future, it would help greatly if you could give us the sample data in a form that we can copy to test with, rather that a picture.
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in
Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.

-----
Let me know the result and I'll get back to you as soon as I can.
Sincerely
Dante Amor
----- --
Thank you! what a stupid mistake...
 
Upvote 1

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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