Richard in Redditch
New Member
- Joined
- Feb 7, 2012
- Messages
- 44
Hello.
I am sure this problem has come up before, but as a tyro I just don't know where my code is going wrong. I an trying to set up a macro, which will copy some data from a summary sheet into another sheet in the same workbook. Here is the code which is giving me angst:
The system (Xl 2013) falls over at the underlined line with error "1004: Select error of Range class failed".
Assistance would be greatly appreciated!
I am sure this problem has come up before, but as a tyro I just don't know where my code is going wrong. I an trying to set up a macro, which will copy some data from a summary sheet into another sheet in the same workbook. Here is the code which is giving me angst:
Rich (BB code):
' Add the new sheet
ActiveWorkbook.Sheets.Add After:=Sheets(LastShtNo)
' Copy heading and formatting to new sheet
Sheets(LastShtNo).Range("2:2").Copy Sheets(NewShtNo).Range("2:2")
Sheets(LastShtNo).Range("D4:G36").Copy Sheets(NewShtNo).Range("d4:g36")
Sheets(LastShtNo).Range("c36").Copy Sheets(NewShtNo).Range("c36")
Range("d4:e35").ClearContents
Sheets(NewShtNo).Range("2:2").Select
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
' Get data
Assistance would be greatly appreciated!
Last edited by a moderator: