ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy Format Error (https://www.excelbanter.com/excel-programming/432973-copy-format-error.html)

LiAD

Copy Format Error
 
Hi,

The following code gives me a run time error 1004 Select method of range
class failed. Would you have any ideas why?

It came from the recorder as well!

Thanks for your help
LiAD

Sheets("6").Select
Range("D10:L23").Select
Selection.Copy
Sheets("1").Select
Range("D10").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
Sheets("6").Select
Range("A1").Select
Sheets("1").Select

Patrick Molloy[_2_]

Copy Format Error
 
where does the code break??


Sheets("6").Range("D10:L23")..Copy
Sheets("1").Range("D10").PasteSpecial Paste:=xlPasteFormats,
peration:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False


"LiAD" wrote:

Hi,

The following code gives me a run time error 1004 Select method of range
class failed. Would you have any ideas why?

It came from the recorder as well!

Thanks for your help
LiAD

Sheets("6").Select
Range("D10:L23").Select
Selection.Copy
Sheets("1").Select
Range("D10").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
Sheets("6").Select
Range("A1").Select
Sheets("1").Select


Sam Wilson

Copy Format Error
 
Which of the selects causes the problem? It should be highlighted in yellow
if you debug.

I'd guess that either "1" or "6" doesn't exist as a sheet, maybe it's been
renamed.

"LiAD" wrote:

Hi,

The following code gives me a run time error 1004 Select method of range
class failed. Would you have any ideas why?

It came from the recorder as well!

Thanks for your help
LiAD

Sheets("6").Select
Range("D10:L23").Select
Selection.Copy
Sheets("1").Select
Range("D10").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
Sheets("6").Select
Range("A1").Select
Sheets("1").Select


Patrick Molloy[_2_]

Copy Format Error
 
typo two dots instead of one, sorry

Sheets("6").Range("D10:L23").Copy 'this line was at fault
Sheets("1").Range("D10").PasteSpecial Paste:=xlPasteFormats,
peration:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False


"Patrick Molloy" wrote:

where does the code break??


Sheets("6").Range("D10:L23")..Copy
Sheets("1").Range("D10").PasteSpecial Paste:=xlPasteFormats,
peration:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False


"LiAD" wrote:

Hi,

The following code gives me a run time error 1004 Select method of range
class failed. Would you have any ideas why?

It came from the recorder as well!

Thanks for your help
LiAD

Sheets("6").Select
Range("D10:L23").Select
Selection.Copy
Sheets("1").Select
Range("D10").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
Sheets("6").Select
Range("A1").Select
Sheets("1").Select


LiAD

Copy Format Error
 
Works now.

THanks

"Patrick Molloy" wrote:

typo two dots instead of one, sorry

Sheets("6").Range("D10:L23").Copy 'this line was at fault
Sheets("1").Range("D10").PasteSpecial Paste:=xlPasteFormats,
peration:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False


"Patrick Molloy" wrote:

where does the code break??


Sheets("6").Range("D10:L23")..Copy
Sheets("1").Range("D10").PasteSpecial Paste:=xlPasteFormats,
peration:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False


"LiAD" wrote:

Hi,

The following code gives me a run time error 1004 Select method of range
class failed. Would you have any ideas why?

It came from the recorder as well!

Thanks for your help
LiAD

Sheets("6").Select
Range("D10:L23").Select
Selection.Copy
Sheets("1").Select
Range("D10").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
Sheets("6").Select
Range("A1").Select
Sheets("1").Select



All times are GMT +1. The time now is 05:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com