View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
mudraker[_22_] mudraker[_22_] is offline
external usenet poster
 
Posts: 1
Default Copy from active workbook to new workbook.


Error in this code

Workbooks("original.xls").Worksheets("shee
5").Range("A10:LastRowWithData").Copy
Destination:=Workbooks("new.xls").Worksheets("Shee t1").Range("A1")

should be

Workbooks("original.xls").Worksheets("sheet 5").Range("A10:"
LastRowWithData).Copy
Destination:=Workbooks("new.xls").Worksheets("Shee t1").Range("A1")



Also if you have one column that has an entry in each row then
suggest you use


dim LastRowWithData
LastRowWithData = Range("a65536").End(xlUp).Row

' Create new workbook

Set NewBook = Workbooks.Add
With NewBook
.SaveAs Filename:="new.xls"
End With


Workbooks("original.xls").Worksheets("sheet 5").Range("A10:"
LastRowWithData).Copy
Destination:=Workbooks("new.xls").Worksheets("Shee t1").Range("A1"

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com