Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Paste into new Excel book not working

Apologies in advance for the basic & clunky code!

I have a workbook containing columns of data and I want to copy and
paste some of the columns into a new workbook, save and close it and
continue with some other manipulations (all of which work fine).

The problem I am having is that when I run the code, it does not error,
but whilst it does the save and close, it doesn't paste anything into
the new workbook.
(even if I record the steps and paste the recorded macro into my code,
it still doesn't do the paste)

Columns("A:E").Select
Selection.Copy
Workbooks.Add
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs
Filename:=Worksheets("Notes").Range("auditpath").V alue &
Workbooks("Original.xls").Worksheets("Notes").Rang e("audit") & ".xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
_
CreateBackup:=False
ActiveWindow.Close

I feel I must be missing something obvious....?

Thanks in advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Paste into new Excel book not working

Hi Raymond

Thanks, but errors on the last line...........

Run time error 9: subscript out of range

And therefore doesn't do the paste.

E

wrote:

Try this:

' The workbook you are copying from
ThisBook=ActiveWorkbook.Name
ThisSheet=ActiveSheet.Name

Workbooks.Add
NewBook=ActiveWorkbook.Name
NewSheet=Activesheet.Namw

Windows(ThisBook).Activate
Sheets(ThisSheet).Select

Columns("A:E").Copy

Workbooks(NewBook).Sheets(newSheet).Range("A1").Pa steSpecial

Raymond

wrote:
Apologies in advance for the basic & clunky code!

I have a workbook containing columns of data and I want to copy and
paste some of the columns into a new workbook, save and close it and
continue with some other manipulations (all of which work fine).

The problem I am having is that when I run the code, it does not error,
but whilst it does the save and close, it doesn't paste anything into
the new workbook.
(even if I record the steps and paste the recorded macro into my code,
it still doesn't do the paste)

Columns("A:E").Select
Selection.Copy
Workbooks.Add
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs
Filename:=Worksheets("Notes").Range("auditpath").V alue &
Workbooks("Original.xls").Worksheets("Notes").Rang e("audit") & ".xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
_
CreateBackup:=False
ActiveWindow.Close

I feel I must be missing something obvious....?

Thanks in advance


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default Paste into new Excel book not working

I would just break the last line down this way.

Workbooks(NewBook).Activate
Sheets(newSheet).activate
Range("A1").PasteSpecial

--
Best wishes,

Jim


" wrote:

Hi Raymond

Thanks, but errors on the last line...........

Run time error 9: subscript out of range

And therefore doesn't do the paste.

E

wrote:

Try this:

' The workbook you are copying from
ThisBook=ActiveWorkbook.Name
ThisSheet=ActiveSheet.Name

Workbooks.Add
NewBook=ActiveWorkbook.Name
NewSheet=Activesheet.Namw

Windows(ThisBook).Activate
Sheets(ThisSheet).Select

Columns("A:E").Copy

Workbooks(NewBook).Sheets(newSheet).Range("A1").Pa steSpecial

Raymond

wrote:
Apologies in advance for the basic & clunky code!

I have a workbook containing columns of data and I want to copy and
paste some of the columns into a new workbook, save and close it and
continue with some other manipulations (all of which work fine).

The problem I am having is that when I run the code, it does not error,
but whilst it does the save and close, it doesn't paste anything into
the new workbook.
(even if I record the steps and paste the recorded macro into my code,
it still doesn't do the paste)

Columns("A:E").Select
Selection.Copy
Workbooks.Add
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs
Filename:=Worksheets("Notes").Range("auditpath").V alue &
Workbooks("Original.xls").Worksheets("Notes").Rang e("audit") & ".xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
_
CreateBackup:=False
ActiveWindow.Close

I feel I must be missing something obvious....?

Thanks in advance



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default Paste into new Excel book not working

I just realized that "NewSheet" was spelled as "newSheet" in the last line.
The Case difference will definitely cause an error message.
--
Best wishes,

Jim


" wrote:

Hi Raymond

Thanks, but errors on the last line...........

Run time error 9: subscript out of range

And therefore doesn't do the paste.

E

wrote:

Try this:

' The workbook you are copying from
ThisBook=ActiveWorkbook.Name
ThisSheet=ActiveSheet.Name

Workbooks.Add
NewBook=ActiveWorkbook.Name
NewSheet=Activesheet.Namw

Windows(ThisBook).Activate
Sheets(ThisSheet).Select

Columns("A:E").Copy

Workbooks(NewBook).Sheets(newSheet).Range("A1").Pa steSpecial

Raymond

wrote:
Apologies in advance for the basic & clunky code!

I have a workbook containing columns of data and I want to copy and
paste some of the columns into a new workbook, save and close it and
continue with some other manipulations (all of which work fine).

The problem I am having is that when I run the code, it does not error,
but whilst it does the save and close, it doesn't paste anything into
the new workbook.
(even if I record the steps and paste the recorded macro into my code,
it still doesn't do the paste)

Columns("A:E").Select
Selection.Copy
Workbooks.Add
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs
Filename:=Worksheets("Notes").Range("auditpath").V alue &
Workbooks("Original.xls").Worksheets("Notes").Rang e("audit") & ".xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
_
CreateBackup:=False
ActiveWindow.Close

I feel I must be missing something obvious....?

Thanks in advance





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Paste into new Excel book not working

Thanks Jim,

I don't get the error message - but I still don't get the data pasted
into the new workbook!

E

PS. If it makes any difference, it's Excel 2003 SP2 .......


Jim Jackson wrote:

I just realized that "NewSheet" was spelled as "newSheet" in the last line.
The Case difference will definitely cause an error message.
--
Best wishes,

Jim


" wrote:

Hi Raymond

Thanks, but errors on the last line...........

Run time error 9: subscript out of range

And therefore doesn't do the paste.

E

wrote:

Try this:

' The workbook you are copying from
ThisBook=ActiveWorkbook.Name
ThisSheet=ActiveSheet.Name

Workbooks.Add
NewBook=ActiveWorkbook.Name
NewSheet=Activesheet.Namw

Windows(ThisBook).Activate
Sheets(ThisSheet).Select

Columns("A:E").Copy

Workbooks(NewBook).Sheets(newSheet).Range("A1").Pa steSpecial

Raymond

wrote:
Apologies in advance for the basic & clunky code!

I have a workbook containing columns of data and I want to copy and
paste some of the columns into a new workbook, save and close it and
continue with some other manipulations (all of which work fine).

The problem I am having is that when I run the code, it does not error,
but whilst it does the save and close, it doesn't paste anything into
the new workbook.
(even if I record the steps and paste the recorded macro into my code,
it still doesn't do the paste)

Columns("A:E").Select
Selection.Copy
Workbooks.Add
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs
Filename:=Worksheets("Notes").Range("auditpath").V alue &
Workbooks("Original.xls").Worksheets("Notes").Rang e("audit") & ".xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
_
CreateBackup:=False
ActiveWindow.Close

I feel I must be missing something obvious....?

Thanks in advance




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Paste into new Excel book not working

Rather than copy columns just copy the range

Count = Range("A65000").End(xlUp).Row

Change the "A" to whatever column holds the most data

Range("A1:E" & Count).Copy rather than Columns("A:E").Copy

Raymond

wrote:
Thanks Jim,

I don't get the error message - but I still don't get the data pasted
into the new workbook!

E

PS. If it makes any difference, it's Excel 2003 SP2 .......


Jim Jackson wrote:

I just realized that "NewSheet" was spelled as "newSheet" in the last line.
The Case difference will definitely cause an error message.
--
Best wishes,

Jim


" wrote:

Hi Raymond

Thanks, but errors on the last line...........

Run time error 9: subscript out of range

And therefore doesn't do the paste.

E

wrote:

Try this:

' The workbook you are copying from
ThisBook=ActiveWorkbook.Name
ThisSheet=ActiveSheet.Name

Workbooks.Add
NewBook=ActiveWorkbook.Name
NewSheet=Activesheet.Namw

Windows(ThisBook).Activate
Sheets(ThisSheet).Select

Columns("A:E").Copy

Workbooks(NewBook).Sheets(newSheet).Range("A1").Pa steSpecial

Raymond

wrote:
Apologies in advance for the basic & clunky code!

I have a workbook containing columns of data and I want to copy and
paste some of the columns into a new workbook, save and close it and
continue with some other manipulations (all of which work fine).

The problem I am having is that when I run the code, it does not error,
but whilst it does the save and close, it doesn't paste anything into
the new workbook.
(even if I record the steps and paste the recorded macro into my code,
it still doesn't do the paste)

Columns("A:E").Select
Selection.Copy
Workbooks.Add
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs
Filename:=Worksheets("Notes").Range("auditpath").V alue &
Workbooks("Original.xls").Worksheets("Notes").Rang e("audit") & ".xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
_
CreateBackup:=False
ActiveWindow.Close

I feel I must be missing something obvious....?

Thanks in advance



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Paste into new Excel book not working

With the correct spellings:

' The workbook you are copying from
ThisBook=ActiveWorkbook.Name
ThisSheet=ActiveSheet.Name

Workbooks.Add
NewBook=ActiveWorkbook.Name
NewSheet=Activesheet.Name

Windows(ThisBook).Activate
Sheets(ThisSheet).Select

Columns("A:E").Copy

Workbooks(NewBook).Sheets(NewSheet).Range("A1").Pa steSpecial

Raymond

wrote:
Hi Raymond

Thanks, but errors on the last line...........

Run time error 9: subscript out of range

And therefore doesn't do the paste.

E

wrote:

Try this:

' The workbook you are copying from
ThisBook=ActiveWorkbook.Name
ThisSheet=ActiveSheet.Name

Workbooks.Add
NewBook=ActiveWorkbook.Name
NewSheet=Activesheet.Namw

Windows(ThisBook).Activate
Sheets(ThisSheet).Select

Columns("A:E").Copy

Workbooks(NewBook).Sheets(newSheet).Range("A1").Pa steSpecial

Raymond

wrote:
Apologies in advance for the basic & clunky code!

I have a workbook containing columns of data and I want to copy and
paste some of the columns into a new workbook, save and close it and
continue with some other manipulations (all of which work fine).

The problem I am having is that when I run the code, it does not error,
but whilst it does the save and close, it doesn't paste anything into
the new workbook.
(even if I record the steps and paste the recorded macro into my code,
it still doesn't do the paste)

Columns("A:E").Select
Selection.Copy
Workbooks.Add
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs
Filename:=Worksheets("Notes").Range("auditpath").V alue &
Workbooks("Original.xls").Worksheets("Notes").Rang e("audit") & ".xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
_
CreateBackup:=False
ActiveWindow.Close

I feel I must be missing something obvious....?

Thanks in advance


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Paste into new Excel book not working

I spotted the rogue 'Namw' and corrected it before trying your code -
gave the runtime error.

What I completely don't understand is , if I record a macro to do the
steps - which does the copy and paste - why running the recorded code
as part of my own code, the paste doesn't work....!

E


wrote:

With the correct spellings:

' The workbook you are copying from
ThisBook=ActiveWorkbook.Name
ThisSheet=ActiveSheet.Name

Workbooks.Add
NewBook=ActiveWorkbook.Name
NewSheet=Activesheet.Name

Windows(ThisBook).Activate
Sheets(ThisSheet).Select

Columns("A:E").Copy

Workbooks(NewBook).Sheets(NewSheet).Range("A1").Pa steSpecial

Raymond

wrote:
Hi Raymond

Thanks, but errors on the last line...........

Run time error 9: subscript out of range

And therefore doesn't do the paste.

E

wrote:

Try this:

' The workbook you are copying from
ThisBook=ActiveWorkbook.Name
ThisSheet=ActiveSheet.Name

Workbooks.Add
NewBook=ActiveWorkbook.Name
NewSheet=Activesheet.Namw

Windows(ThisBook).Activate
Sheets(ThisSheet).Select

Columns("A:E").Copy

Workbooks(NewBook).Sheets(newSheet).Range("A1").Pa steSpecial

Raymond

wrote:
Apologies in advance for the basic & clunky code!

I have a workbook containing columns of data and I want to copy and
paste some of the columns into a new workbook, save and close it and
continue with some other manipulations (all of which work fine).

The problem I am having is that when I run the code, it does not error,
but whilst it does the save and close, it doesn't paste anything into
the new workbook.
(even if I record the steps and paste the recorded macro into my code,
it still doesn't do the paste)

Columns("A:E").Select
Selection.Copy
Workbooks.Add
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs
Filename:=Worksheets("Notes").Range("auditpath").V alue &
Workbooks("Original.xls").Worksheets("Notes").Rang e("audit") & ".xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
_
CreateBackup:=False
ActiveWindow.Close

I feel I must be missing something obvious....?

Thanks in advance


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Paste into new Excel book not working

This has me completely stumped.....

No error messages, and just the paste statement doesn't work....



wrote:

I spotted the rogue 'Namw' and corrected it before trying your code -
gave the runtime error.

What I completely don't understand is , if I record a macro to do the
steps - which does the copy and paste - why running the recorded code
as part of my own code, the paste doesn't work....!

E


wrote:

With the correct spellings:

' The workbook you are copying from
ThisBook=ActiveWorkbook.Name
ThisSheet=ActiveSheet.Name

Workbooks.Add
NewBook=ActiveWorkbook.Name
NewSheet=Activesheet.Name

Windows(ThisBook).Activate
Sheets(ThisSheet).Select

Columns("A:E").Copy

Workbooks(NewBook).Sheets(NewSheet).Range("A1").Pa steSpecial

Raymond

wrote:
Hi Raymond

Thanks, but errors on the last line...........

Run time error 9: subscript out of range

And therefore doesn't do the paste.

E

wrote:

Try this:

' The workbook you are copying from
ThisBook=ActiveWorkbook.Name
ThisSheet=ActiveSheet.Name

Workbooks.Add
NewBook=ActiveWorkbook.Name
NewSheet=Activesheet.Namw

Windows(ThisBook).Activate
Sheets(ThisSheet).Select

Columns("A:E").Copy

Workbooks(NewBook).Sheets(newSheet).Range("A1").Pa steSpecial

Raymond

wrote:
Apologies in advance for the basic & clunky code!

I have a workbook containing columns of data and I want to copy and
paste some of the columns into a new workbook, save and close it and
continue with some other manipulations (all of which work fine).

The problem I am having is that when I run the code, it does not error,
but whilst it does the save and close, it doesn't paste anything into
the new workbook.
(even if I record the steps and paste the recorded macro into my code,
it still doesn't do the paste)

Columns("A:E").Select
Selection.Copy
Workbooks.Add
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs
Filename:=Worksheets("Notes").Range("auditpath").V alue &
Workbooks("Original.xls").Worksheets("Notes").Rang e("audit") & ".xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
_
CreateBackup:=False
ActiveWindow.Close

I feel I must be missing something obvious....?

Thanks in advance




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cut and paste is not working in excel 2003 mdeckman Excel Discussion (Misc queries) 1 May 8th 09 05:12 PM
Paste not working in Excel 07 Richard Excel Discussion (Misc queries) 1 May 6th 09 01:51 AM
Paste and Paste Special No Longer Working - Excel 2003 SheriJ Excel Discussion (Misc queries) 2 January 15th 09 09:23 PM
Excel Work Book Copied Into Word With Paste Special, Excel Workboo MAB Excel Discussion (Misc queries) 0 February 12th 08 06:59 PM
paste special not working in excel Lisa Excel Queen Excel Discussion (Misc queries) 1 June 5th 06 06:56 PM


All times are GMT +1. The time now is 11:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"