Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
problem coping data from 1 sheet to new sheet | Excel Programming | |||
Coping a whole row to another sheet | Excel Programming | |||
WHY DOES COPING FROM SHEET TO SHEET INCREASE SIZE DRAMATICALLY? | Excel Discussion (Misc queries) | |||
Coping Contents of one Sheet into Another Workbook | Excel Programming | |||
Coping a sheet | Excel Programming |