LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Need a little help coping a sheet from one workbook to another.

Below is the code I have. It works in another macro, but not in a new one I
am working on. Not sure where I went wrong. I get the error at this line
wbA.Sheets("C").Copy wbNew.Sheets("PW_CRAD_C")
The error is run time error 9, subscript out of range.

Sub ExportCA_Only()
'
' ExportCA_Only Macro
' Macro recorded 9/9/2002 by rgrisber
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Range("B1").Select
Selection.AutoFilter Field:=2, Criteria1:="=CA", Operator:=xlOr, _
Criteria2:="=WP"
Columns("C:F").Select
Selection.Copy
Worksheets.Add.Name = "C"
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
'need to add a sheet to master and then copy the sheet
Dim wbA As Workbook
Dim wbNew As Workbook
With Application
SheetsInWb = .SheetsInNewWorkbook
.SheetsInNewWorkbook = 1
.DisplayAlerts = False
.ScreenUpdating = False
End With
Set wbA = ThisWorkbook
Set wbNew = Workbooks.Add
With wbNew
.SaveAs Filename:="V:\CSPR\PW_CRAD_C.csv"
End With

wbA.Sheets("C").Copy wbNew.Sheets("PW_CRAD_C")
'wbNew.Sheets("Sheet1").Delete
Dim myName As Name
Dim WorkbookLinks As Variant
Dim i As Long
Dim myWB As Excel.Workbook

Set myWB = ActiveWorkbook
....
end sub
 
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
problem coping data from 1 sheet to new sheet [email protected] Excel Programming 1 May 7th 09 07:58 PM
Coping a whole row to another sheet daisy2008 Excel Programming 5 December 18th 08 07:31 PM
WHY DOES COPING FROM SHEET TO SHEET INCREASE SIZE DRAMATICALLY? Jerry Excel Discussion (Misc queries) 0 June 1st 07 05:06 PM
Coping Contents of one Sheet into Another Workbook Egon Excel Programming 2 December 1st 05 05:24 PM
Coping a sheet James Excel Programming 2 April 7th 04 06:26 PM


All times are GMT +1. The time now is 06:51 AM.

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

About Us

"It's about Microsoft Excel"