View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
SIGE SIGE is offline
external usenet poster
 
Posts: 206
Default Copy Range Issue

Hello,
Would like to copy all the Ranged Names starting with "VBA" to a new workbook.
1. Syntax jams on :
Range(nme.Name).Copy '''''GRRRRRRR'''''''
2. I do not create a new workbook for every name I am exporting do I?

Sige

Sub sige()
Dim ThisBook As Workbook
Dim ExpBook As Workbook
Dim nme As Name

Set ThisBook = ActiveWorkbook
Set ExpBook = Workbooks.Add(xlWorksheet)
For Each nme In ThisBook.Names
If Left(nme.Name, 3) = "VBA" Then
MsgBox nme.Name
Range(nme.Name).Copy '''''GRRRRRRR'''''''

With ExpBook
.Worksheets(1).Range(Range(nme.Name).Address).Past e
.SaveAs FileName:=ThisWorkbook.Path & "\temp.xls", _
FileFormat:=xlWorkbook
.Close SaveChanges:=False
If Err < 0 Then MsgBox "Cannot export" & _
ThisWorkbook.Path & "\temp.xls"
End With
Else

MsgBox "No names to export"
Exit Sub
End If
Next nme
End Sub