View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default HELP = VBA Code To Import Worksheets Into A WorkBook

Sub InportSheets()

Folder = "c:\temp\"
FName = Dir(Folder & "*.xls")
Do While FName < ""
With ThisWorkbook
Set bk = Workbooks.Open(Filename:=Folder & FName)
If bk.Sheets.Count 1 Then
MsgBox ("More Then one sheet in " & FName)
End If
Worksheets.Copy after:=.Sheets(.Sheets.Count)
bk.Close savechanges:=False
End With

FName = Dir()
Loop

End Sub


"tommo_blade" wrote:

Hello,
does anyone have any snippets/examples of code that will help
me do the following:-

I have a directory that will contain 'n' number of excel workbooks
that have been emailed to me, there is a **single worksheet within
this workbook and it will contain data, cell functions and macro's, I
am going to put a button on my master workbook and I want that to
import all workbooks from this directory and have them inserted as a
seperate worksheet within my master workbook keeping all the original
imported worksheet data, functions & macro's intact.

** I may need to test that the imported worksheet only has the ONE
worksheet, anymore and I need to know about it...

any help/guidance is appreciated...


thanks in advance, Mark.