Moving sheets to another file

G

Guest

I'm trying to move certain sheets to a selected file and getting a "..out of
range" error.
Help?

Sub SendData()

Dim wb As String
wb = ThisWorkbook.Activate

Dim SendDataFname As String

SendDataFname = Application.SendOpenFilename("Excel files (*.xls),
*.xls")

Workbooks.Open SendDataFname

Sheets(Array("sheet2", "sheet3", "sheet4")).Move _
After:=Workbooks(wb).Sheets("sheet1")
Windows(SendDataFname).Activate
ActiveWorkbook.Save
ActiveWindow.Close

ThisWorkbook.Activate

End Sub
 
C

Chip Pearson

Tim,

Change
wb = ThisWorkbook.Activate
To
wb = ThisWorkbook.Name


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top