B
Brian S
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
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