ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copy cell format (https://www.excelbanter.com/excel-programming/396252-copy-cell-format.html)

ksh

copy cell format
 
Hello -
I recorded a macro to copy the format of a range of cells on sheet2 to an
equal range of cells on sheet 1. When I run the macro it copies the data
from sheet 2, but then it runs into a problem on the
"Range("D34:D49").Select" step and gives me the following error.

select method of range class failed

Sheets("Sheet2").Select
Range("D9:D24").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
Range("D34:D49").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Thanks for any info you can give me on this.

ksh

copy cell format
 
I found the problem. I had the code attached to a command button in sheet 2.
I moved the macro to module in the workbook and it works fine now.

"ksh" wrote:

Hello -
I recorded a macro to copy the format of a range of cells on sheet2 to an
equal range of cells on sheet 1. When I run the macro it copies the data
from sheet 2, but then it runs into a problem on the
"Range("D34:D49").Select" step and gives me the following error.

select method of range class failed

Sheets("Sheet2").Select
Range("D9:D24").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
Range("D34:D49").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Thanks for any info you can give me on this.



All times are GMT +1. The time now is 12:14 PM.

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