View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default VBA code to import worksheets from other workbooks

Hi Alice,

Am Mon, 22 Apr 2013 15:55:37 +0100 schrieb Alice21:

Is there a VBA code that I can put into a Master workbook that will
import sheets from four different workbooks?

I only want to import sheets if they contain "W93004" in the sheet
name.


open Master and the other 4 workbooks.
Code for workbook "Master":

Sub Import()
Dim wbk As Workbook
Dim wsh As Worksheet

ThisWorkbook.Activate
For Each wbk In Application.Workbooks
If wbk.Name < "Master.xlsm" Then
For Each wsh In wbk.Worksheets
If InStr(wsh.Name, "W93004") 0 Then
wsh.Copy _
after:=Workbooks("Master.xlsm").Sheets(Sheets.Coun t)
End If
Next wsh
End If
Next wbk
End Sub


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2