Select method of Range class failed

WallisAggie646777

New Member
Joined
May 6, 2020
Messages
8
Office Version
  1. 365
Platform
  1. Windows
I did a record macro to copy a range of cells from one worksheet and paste into another worksheet which worked when recording the macro with my keystrokes.
When I put the code generated from the run macro into my code and try to execute it, and get the Select method of Range class failed error message. The code that fails is shown below.
There are no merged cells.
Sheets("Groups").Select
Range("O7:T32").Select 'THE ERROR OCCURS ON THIS LINE OF CODE
Application.CutCopyMode = False
Selection.Copy
Sheets("Temp").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
58,372
Office Version
  1. 365
Platform
  1. Windows
Welcome to the Board!

Do you have any hidden rows or columns, or any protection going on?
Other than merged cells, those are the only other two things I can see would give you issues is trying to select a range.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
60,188
Office Version
  1. 365
Platform
  1. Windows
On top of what Joe has asked, where is the code located? Is it in a standard module, sheet mode, ThisWorkbook module, or somewhere else?
 

WallisAggie646777

New Member
Joined
May 6, 2020
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Welcome to the Board!
On top of what Joe has asked, where is the code located? Is it in a standard module, sheet mode, ThisWorkbook module, or somewhere else?
The code is in the "Weekly" worksheet mode

Do you have any hidden rows or columns, or any protection going on?
Other than merged cells, those are the only other two things I can see would give you issues is trying to select a range.
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,141
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
The code is in the "Weekly" worksheet mode
Then you need to change
VBA Code:
Range("O7:T32").Select
to
VBA Code:
Sheets("Groups").Range("O7:T32").Select

or avoid the selecting altogether
VBA Code:
Sheets("Groups").Range("O7:T32").Copy
Sheets("Temp").Range("A1").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
 

Forum statistics

Threads
1,136,853
Messages
5,678,132
Members
419,746
Latest member
tysonboy82

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
Top